I see one issue...the Get Children node. Is UI Element Get Children, not UI Canvas Get Children.
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
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.
Not even that works. I meant "HUD LOADED INTO ENTITY" ftr
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.
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.
This is what I currently have. And I can get this "(Script Canvas) - HUD LOADED INTO ENTITY: " 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.
Getting Access to the CanvasAccepted Answerasked 2 years ago
RayCast (Script Canvas)asked 4 years ago
How can I create a global variable in Script Canvas? [Lumberyard 1.14]Accepted Answerasked 4 years ago
[Unreal] How to remove a PlayerSession when Player leaves a GameSession?asked a year ago
How do you tell the difference Level entity and other entitiesAccepted Answerasked 2 years ago
Creating a Main Menu with Script CanvasAccepted Answerasked 4 years ago
How to access functions from a script on a diffrent entity in lua?Accepted Answerasked 4 years ago
A consumer of an Event aware on how to retrieve relevant data ... a business model barrier?asked 2 years ago
I am getting CORS errors in S3 console, is this a bug with AWS S3?asked 5 months ago
Playing a sequence on start using Script Canvas?Accepted Answerasked 5 years ago