x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How to dynamically change Texture variable?

Hi.

I want to change picture of the Texture variable. I am trying to change it with Texture - Set Source File Path, but it method get many errors:

alt text

alt text

My String variable has value

/Game/GameObjects/Furniture/Tables/Wood_Table/Wood_Table_logo

alt text

How to change this "cursor picture"?

Thank you very much.

Product Version: UE 4.8
Tags:
more ▼

asked Jun 18 '15 at 01:34 PM in Blueprint Scripting

avatar image

Arthur Khusnutdinov
605 89 95 250

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

Solved with custom BP:

.h file:

 UFUNCTION(BlueprintCallable, meta = (FriendlyName = "MyLoadTextureFromPath", Keywords = "my load texture from path"), Category = Game)
 static  UTexture2D* MyLoadTextureFromPath(const FString& Path);

.cpp file:

 UTexture2D* AMyNativePlayerController::MyLoadTextureFromPath(const FString& Path)
 {
     if (Path.IsEmpty()) return NULL;
 
     /*FString PathToLoad = "/Game/Textures/YourStructureHere";
     UTexture2D* tmpTexture = LoadTextureFromPath(PathToLoad);*/
 
     return Cast<UTexture2D>(StaticLoadObject(UTexture2D::StaticClass(), NULL, *(Path)));
 }

Result:

alt text

screenshot_139.png (226.7 kB)
more ▼

answered Jun 19 '15 at 08:50 AM

avatar image

Arthur Khusnutdinov
605 89 95 250

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

A string isn't just a pointer ot a texture. You have to load it. But i'm afraid you'll need to write a custom BP node for that (but it's easy, don't worry, it will be about 5 code lines).

more ▼

answered Jun 18 '15 at 02:25 PM

avatar image

zamy
391 17 12 32

avatar image Arthur Khusnutdinov Jun 19 '15 at 08:15 AM

Can you provide an example?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

This is exactly what I need but I don't know how to import this code in my project. Would I need to create a new project or there is a way to add this c++ code directly to my project? If you have some time Arthur (or someone else), can you contact me here or on skype => consomer.yourself2 . Thanks for sharing the code by the way and have a good day!

Gabriel.

more ▼

answered Mar 16 '16 at 07:10 AM

avatar image

Xosh project
356 3 6 15

avatar image iKeepBelieving Mar 16 '16 at 08:45 AM
avatar image Xosh project Mar 16 '16 at 06:20 PM

Only the name of the tutorial look awesome, thanks!

avatar image Xosh project Mar 16 '16 at 06:32 PM

If I say nothing wrong, I need to choose the «Blueprint Function library»for this? I need to use this function in widget blueprint.

I have a problem, I'm not really good at c++. What I need to put where is AMyNativePlayerController?

I also change friendlyName to DisplayName, unreal tell me to do this (I trust unreal more than me for this hehe)

There a little screenshot of the .cpp , .h and the message Log.

alt text

If you see something wrong tell me please.

sans titre-1.jpg (640.4 kB)
avatar image iKeepBelieving Mar 16 '16 at 11:09 PM

Hi! I think that Arthur created new C++ Class (with Player Controll Parent i bet) and called it AMyNativePlayerController. Then he added this code into it's .h and .cpp. Then he pressed compile. Then he created Blueprintclass based on AMyNativePlayerController. And works with it as if it was just Player Controller Blueprint class but with some usefull modification for u.

Try to put UMyBluePrintFunctionLibrary there ;)

avatar image Xosh project Mar 16 '16 at 11:42 PM

Thanks for your answer! I try to change «AMyNativePlayerController» for «UMyBluePrintFunctionLibrary» but it didn't work :(. I also try «MyBluePrintFunctionLibrary», same but without U, didn't work too. Unreal give me exactly the same error. If you have another idea I'm open to everything!

EDIT: Arthur directly help me, thanks for your answer, we were close to the answer ! It was «UMyBlueprintFunctionLibrary» not «UMyBluePrintFunctionLibrary». All of this for an uppercase :p Thanks again for your help!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question