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"

Change UI text color based on level

I need to change the UI text color for each level. Currently I've made a function out of the color similar to https://answers.unrealengine.com/questions/483337/umg-how-to-change-text-color-with-onunhovered.html I then wanted to use a variable to select what colour based on the level loading. I'm new to UE so not sure if this the best way to do it.

Product Version: UE 4.17
more ▼

asked Jan 04 '18 at 11:30 AM in Using UE4

avatar image

1 1 3 2

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

1 answer: sort voted first

Hey there, welcome to the Unreal 4 community!

You can create a custom event or function that checks which level you are currently in and set the color variables based on that. Using this node: https://docs.unrealengine.com/latest/INT/BlueprintAPI/Game/GetCurrentLevelName/

If this is not enough info, I can try to give a more in-depth explanation.


more ▼

answered Jan 04 '18 at 03:36 PM

avatar image

283 9 19 22

avatar image zakarykinnaird Jan 05 '18 at 02:28 AM

That's very useful, currently I've got something like this. A more detailed explanation would be amazing, I'll keep on working on it.

alt text

color.jpg (251.8 kB)
avatar image Samuelb Jan 05 '18 at 12:09 PM

Ok that looks pretty good, you need to connect the get current level Node before the return node. Then branch off the return value of the level name, if it is equal to "level1" set the selected color, if it is not, branch off the false execution and check if its equal to the next level etc.

Something like this maybe:

Not the best way but here is the basic idea

Hopefully this helps, let me know if you run in to trouble. -SamuelB

avatar image zakarykinnaird Jan 06 '18 at 02:15 AM

Great that works perfectly. Just need it only check once as it runs constantly.

alt text

avatar image TitanicGames Jan 06 '18 at 02:57 AM

Hey there,

If you just want to call it once instead of constantly updating it through bindins, you can run that same code from EventConstruct (if you're using a widget blueprint) or EventBeginPlay (if you're using a normal blueprint). I'm assuming you're using widgets though, so you'd go with the former. Here's an example: alt text

In this case, "YourText" is a Text widget that I added to the canvas of the widget blueprint. But you can do this for nearly every widget type (image, progress bar, text, etc.). Hope you find that useful!

updatecoloronce.png (135.5 kB)
avatar image Samuelb Jan 06 '18 at 11:57 AM

Yea adding to the construct should work

(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