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"

Set Visibility of Widget from another Widget

Essentially I have a main menu widget, and an options widget. This seems the best way to do it, unless I'm wrong, instead of doing it all in one big widget blueprint. The problem becomes that I have to use create widget, and then destroy said widget every time, instead of just unhiding and hiding the options menu.

I am not sure how to let two widgets... see each other and their variables though, so that they can interact with them. Like I'd like the options menu to be able to hide itself and at the same time, unhide the main menu, but they can only interact with their own variables it seems.

Product Version: UE 4.14
more ▼

asked Dec 24 '16 at 02:24 AM in Blueprint Scripting

avatar image

1 1 2 3

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

3 answers: sort voted first

You can use "Get All Widgets Of Class" to find the widget you want to touch, then call any functions that are in that widget to do your desired action.

So in your main menu have a function that unhides itself when called. Then in your options menu call "GetAllWidgetsOfClass -> MainMenu" -> "Unhide MainMenu function".

Alternatively (and probably less performant), you could probably also put a variable on your character or in your game mode, that those widgets then watch to determine if they should be visible or not.

Basically, "isInOptionsMenu" bool on your character, and the MainMenu/Options hides/unhides itself whenever that value changes.

more ▼

answered Dec 24 '16 at 07:37 AM

avatar image

131 3 4 11

avatar image Morkath Dec 24 '16 at 07:49 AM

Oh, you can also create a reference variable when you first create the widgets, that will let you directly access the variables.

alt text

Then just call into wherever you are storing this ref, from your widget, to modify the other.

avatar image SerWind Jan 11 '17 at 06:18 AM

I thought I had it set that when I received an answer it would go to my email but I never got one so I just assumed no one had answered. Regardless thank you for the response.

In regards to the solution: Do you think just keeping a variable/variables on some invisible object in the world is the best way to do it? I mean is that how you would do it? I'll be honest I don't know a lick of code so this is a massive learning experience for me.

That being said I'd like to drop a quick other question for you if you don't mind: I want to make a game that is in essence just a bunch of menus, with a clickable overworld. I have been looking around for tutorials on how to make more complex menus but the only Unreal documentation I can find is very simple main menu tutorials. I was wondering if you knew of any better ones or if you had any tips on maybe how to learn menus with Unreal?

Thanks again.

avatar image Morkath Jan 11 '17 at 07:31 PM

Like I mentioned, putting it in the character blueprint, or the game mode blueprint is probably your best option. If you are doing a menu only game, with no character blueprint, I would toss it in the game mode blueprint.

I'm mostly self taught, so I don't really use tutorials, sorry.

For a menu only game, you would basically be extrapolating on the basic menu tutorial. Clicking a button closes/hides the current widget and opens the next one in the chain that you want. Complexity of the menus is basically determined by the layout you use to make it.
Make use of panels to build your widget (the widget switcher and the vertical / horizontal boxes, etc), and you can do pretty much anything layout wise.

For example, an overworld map would most likely be a two uniform grid's, One would be the background displaying the map, filled with images and/or buttons.
The second would be empty, except for one image, to display the player. Then you simply manipulate the row/column number to move them around.

Hope that helped!

avatar image SerWind Jan 11 '17 at 11:12 PM

Definitely very helpful. I suppose I'll just poke around and see what I can learn. Did you have a background in code? I know it definitely helps, but part of the reason I chose Unreal and blueprints is because I have very little knowledge in coding.

Mind if I pick your brain just a little more? I don't remember the widget blueprints having access to the level blueprint, but I could be completely wrong.

Also wouldn't having a widget constantly watching a variable be hell on performance? Especially if you have many menus?

avatar image Morkath Jan 12 '17 at 05:26 AM

Coding and design background.

I assume you mean game mode, not level. Yes, it can access it, simply do a get game mode, then cast it to your game mode.

Yeah, you don't want to put a ton of stuff on tick, only if it absolutely needs to update every tick. Otherwise you can set a timer, and have it run every X seconds. For this scenario, you just want to check the variable when you are opening/closing a widget via button click, so it wouldn't be an issue in any way.

avatar image SerWind Jan 12 '17 at 10:39 AM

Honestly I am just going to keep asking questions because this seems like a great opportunity to learn. Feel free to stop answering at any time.

When the level loads I create two widgets. The main menu widget which is visible and the options menu widget which is hidden.

Inside of the main menu widget I want to be able to set the options menu to visible. So I am trying to... cast to the options widget, this is correct right? But then it wants something in the first object input, which I am assuming is the parent class, which would be the very options menu I am trying to manipulate? Which I don't have access to which is why I am casting. It's very confusing. ![alt text][1]

Any insight you can shed on this would be fantastic. This is the biggest hangup I have hit. [1]: /storage/temp/121712-l9ev2l1[1].png

l9ev2l1[1].png (57.6 kB)
avatar image Morkath Jan 12 '17 at 08:38 PM

Yeah, it is looking for a reference to the options widget. Casting is used to tell the system what an object/reference is, if it is stored as a generic type, not to find that object. For example, when I use "Get Game Mode", it returns a generic game mode item, that I can then either call generic baseline game mode functions on, or I can cast it to my specific game mode, so I can then call any custom variables or functions I have created in it.

What you would want to do, is something like, "Get widgets of class", set to the class type of that widget. Then manipulate that. If you are going to be using it regularly, you should create a reference variable of that widget type, and store the reference when you grab it the first time, to save cpu.

If you expect to need them in multiple widgets, its another thing you could store in the game mode, so each copy doesn't need it own reference to it.

avatar image SerWind Jan 14 '17 at 05:30 PM

I spent a considerable amount of time looking into just what exactly casting was and with your help I think I am finally getting it. It seems really important considering it looks like it's used all the time in tutorials.

That being said I had tried out what you mentioned beforehand, the get widgets of class thing, and trying numerous ways it never seemed to work.

Attached are the two images showing exactly how I tried to go about it. Not sure what I did wrong here. I even showed it to someone else who works with Unreal blueprints and they couldn't tell me. Any insight you can shed on this?

I tested to make sure it was reaching the execution of set visibility itself. I also know they exist properly, for example if I just have it so that visibility is set from execution to visible it will be there. Doing it this way doesn't work though. alt text

alt text

avatar image Morkath Jan 14 '17 at 08:04 PM

Yep, that's a bug I was hitting that CS says they are unable to reproduce.


avatar image SerWind Jan 14 '17 at 08:54 PM

Well that's odd, and also heartbreaking. I guess it's time to work around it.

avatar image SerWind Jan 15 '17 at 07:30 PM

So just in regards to the original question then, you said you can create a reference to the widget and then just call into wherever you are storing the reference. So you can't pass the reference to a widget class? Do you think you could expand on the calling into the object to access the reference?

avatar image Morkath Jan 15 '17 at 09:04 PM

You can pass the reference. You would just need to create an empty reference of that type in the widget, then when you create the widget set that reference in the creating widget, and then call a function that constructs everything. So like; CreateWidgetA -> SetWidgetARef(MainRef) ->CallWidgetAConstructionFunction

Calling into to get the reference is as simple as; GetGameMode->CastToMyGameMode->GetRef

If you only need to get the reference once, I would just get it from the game mode. If you are going to need to get it repeatedly in that widget, pass in the reference. Basically need to judge where you want to expend the memory to keep the reference active, or where you want to spend the cycles to grab it.

avatar image SerWind Jan 16 '17 at 07:23 PM

So I thought about doing it that way, putting the creation of the widgets in the gamemode, but then I realized I'd have to make two gamemodes, otherwise I'd have the main main menu on every level. Which I guess making two game modes isn't that big of a deal, just something a new person like me might have some trouble with. I decided to take one more crack at getting a work around, considering that get all widgets of type is glitched. I thought, hey, what if I just set references to the widgets in the level blueprint and then made those variables public, I should be able to see them right? But I can't see them from anywhere else.

Is this normal or am I just doing something wrong? I'm guessing if it was that easy you would have told me. alt text

yhgwzn1[1].png (271.0 kB)
avatar image Morkath Jan 20 '17 at 08:34 AM

Get widget's works fine, it is the setting visibility part that glitches out. You can still get/set the variables.

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

Hello everybody. I'm working with widgets, I use them like 3D elements. There's a simple to set different visibility to a widget's element, instead of using lots of widgets. I simply created a widget. Inside I put a text wich activates a button (actually it make it appears) that you can use again. Allalt text the elements are inside the same widget. Here's the blueprint, hope this can be helpful.

more ▼

answered Apr 04 '17 at 04:44 PM

avatar image


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

Also if you want to set visibility of another widget you can simply use this Blueprint. Inside the Get All Widget of Class function I selected the widget I wanted to modify. Note that Top Level Only is unchecked. alt text

more ▼

answered Apr 04 '17 at 04:57 PM

avatar image


(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