I have a MainHUD
widget and I have used UI_DynamicCrosshair
and UI_WeaponInfo
in it. Is Variable
is ticked for them both in MainHud
.
I am creating the widget
and adding to the viewport in my FPS_Character
blueprint.
But the children are not accessible as properties of MainHUD
widget in FPS_Character
blueprint. I only have the option to cast the MainHUD
widget into its children but that is useless.
You’re on the right track. A UMG Widget class knows its own member variables, but you may have to cast to User Widget for some things before you can cast them to the class that’s aware of those members and children.
Either way, you don’t cast to the child class to access the child widget, because casting means treating something like the other. For example, a human may own a car, and have that car in its variables, but you cannot cast a human to a car, because the car is not a type of human. What you CAN do is cast the human to a specific type of human, like DudeWithShortsAndSandals (a blueprint class derived from Human), and access his Beach Buggy variable (a reference to a Car actor) from there.
You don’t CAST to the child widget, you cast from the non-specific reference of a thing, to the specific class that has a variable in it for the child you want to access, and then you can pull a wire out of it and get its child widget from there. Once you have a reference to the child widget, you can do what you need with it from there.