If my player character detects that the current level is mainmenu, i want it to construct a widget and add it to the viewport, here’s how i made it:
When the widget is constructed, it prints a string:
Now here’s what happens when i click play:
It was still correctly showing two days ago. I even updated the project from 4.17 to 4.18, but that didn’t fix it. It happens in Play in editor, Standalone and Packaged. All other widgets show up, except for this one. What am i doing wrong?
Can you double check a couple of things:
- Root of the widget (and its elements) are set to something else than Hidden or Collapsed
- Do you load a level after creating the widget?
- Do you ever remove the widget from the viewport? (perhaps you forgot, who knows)
- As a test, put Print String into widget’s Tick and confirm you see it spam.
Could you show the hierarchy of the widget?
Promoting the variable did nothing, and isValid always returns true
The node is in the player character, and yes, after disconnecting that wire nothing changes
- The root and everything else is set to Self Hit Test Invisible, but nothing happens when i set them to Visible
- No
- No
- It doesn’t spam for some reason
By hierarchy you mean this? https://i.imgur.com/q4lVqsb.png
It all looks good at a glance. #4 is the worrying part. Widgets that are not in the viewport do not Tick, meaning your widget is never added.
Could you do one more thing. As soon as you create your widget, promote the return value to a variable (RMB the return pin > promote). Perhaps, somehow, your widget is getting Garbage Collected.
Also, in the same blueprint where you create the widget, get that promoted variable, drag a wire and check isValid - print that boolean out in Tick.
The create widget node, which object is in? If you disconnect the execution wire after adding to viewport, nothing changes?
To me, it all seems as if you removed the widget from the viewport after creating it. The very fact that it does not tick hints at it not being the viewport. The widget is valid, meaning it’s being referenced by something.
Can you test it with another widget, other than MainMenu?
You mean creating another widget? That does work and different ones display correctly
I meant that you could temporarily replace the menu widget with any other widget and see if this one displays. Perhaps there is an issue with the menu widget itself.
edit- misread your post. So it seems the MainMenuUI widget itself is the culprit then.
You have a fade out element in there, perhaps it coves everything somehow.
Since it’s called fade out, I’m assuming you’re animating it, perhaps the default value is set incorrectly.
Hard to advise without seeing the setup.
I think that hidden and/or collapsed widgets do not tick either - consider tick printing the widget’s visibility enum and see what you get.
I found out there’s something in the widget’s BeginPlay that prevents it from spawning. Investigating it right now
Actually no, BeginPlay is fine and fully executes, but Tick doesn’t
Something’s wrong here, if i disconnect widget’s BeginPlay entirely it works, but when i connect a print string right at the end of the event then it prints, but the widget doesn’t show up
Nvm, i fixed this. I made a very bad oversight in setting visibility of certain properties in a different widget. I didn’t connect a node to “target” in set visibility and the whole widget just hid itself.
Oh, well. Sounds like the #1 I mentioned ;p