- Newest
- Most votes
- Most comments
I see one issue...the Get Children node. Is UI Element Get Children, not UI Canvas Get Children.
Hey Wcb,
Three things I would check here:
-
That the Get hud node is actually being set to an entity. Does it have your player or hud entity as the value in the variable manager? Add a print node to print the EntityId value after GetHud (it should look normal, i think it does spit out a dummy entityId value if it isn't set)
-
That the entity with the canvas had enough time to load the canvas before you are asked for a reference to it. You might just avoid this problem by leaving the canvas unloaded and calling the load canvas node in this script you have posted. Otherwise I see that there is a 'On Canvas Loaded Into Entity' node that you can use to be sure the canvas ready to reference. The node should either fire immediately on connecting if the canvas is already loaded and ready or it will fire at some point after when it is ready.
-
If that reference to the canvas is all good, ensure that the canvas actually has child UI elements. Perhaps add a print node right after 'For Each' and see how many times it fires and that the EntityIds are all unique and match the count you would expect.
I decided to just do this
REMOVEDUPLOAD
I made a script canvas just for the entity with the canvas and attached the script canvas to it. This doesn't have any output at all. It doesn't print a thing. The UI Canvas has children.
It won't even spark that event.
The canvas loads fine but it doesn't seem to be loading into the entity. I know the canvas loads because I can see the GUI.
REMOVEDUPLOAD
Not even that works. I meant "HUD LOADED INTO ENTITY" ftr
@REDACTEDUSER
Another thing to check is that the UI component is on the same entity you are referencing in the 'GetHud' node. If, in your level layout, your top-level 'Player' entity has the UI component and you are referencing 'Player' in GetHud, that all sounds fine. If your Player entity has a child entity called Hud or something, and the child actually the entity with the UI component, then the child component needs to be the referenced EntityId in GetHud.
Here is an older forum post with a two-part tutorial on working with the UI in scriptcanvas, it has the scriptcanvas graph there too, the layout is probably jumbled, it's from an older version of Lumberyard. The tutorial doesn't cover cross-entity referencing, but plenty on wrangling UI canvases with some of the caveats of referencing them.
https://forums.awsgametech.com/t/creating-a-main-menu-with-script-canvas/5619/6
REMOVEDUPLOAD
If I do this then I can get HUD LOADED INTO CANVAS print statement to work. But it still doesn't print children.
For that graph to work, it would have to be on the entity with the UI component, because the source is set to self.
If this graph is on a different entity you'll need to change the source.
The graph ("hud.scriptcanvas") is now connected to an entity called "hud" which has a canvas ref attached called "hud" which is hud.uicanvas that has children.
I did that to attempt to isolate what the problem is. I have no idea why I can't get access to the children in hud.uicanvas which is attached to entity "hud" which has the above graph in it which is a scriptcanvas "hud.scriptcanvas" It will not print out any of the children.
REMOVEDUPLOAD
This is what I currently have. And I can get this "(Script Canvas) - HUD LOADED INTO ENTITY: [706703339973959]" but that's all I get.
I should get all the children but I do not. I have no idea how to know if that big long number is a "dummy" number or not.
OK that sounds like a good setup to work from. That EntityId looks fine.
I also tried a different uicanvas file just to see if the hud one is corrupted. It doesn't work with either uicanvas file. Can't print out children.
Those nodes that have the same name but slightly different categories get me plenty.
DOH! all I did was search "get children" and assumed since it was UI it was appropriate. That fixed it. THANK YOU!
You got it! That tutorial might still be worth a look for the caveats...there is another category, UI Canvas Manager that can be useful but you have to mind the pathname, that's covered in one of those pdfs.
Adding new answers, comments, and votes is disabled.
Relevant content
- Accepted Answerasked 6 years ago
- asked 6 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 9 months ago