But It seem I cant get a reference to the variable
‘Book Spine UI’ does not inherit from ‘Book Spine 3DWidget’ ( Cast To BookSpineUI would always fail).
as the warning says, you don’t need to cast to a class you already have a reference to.
The Spawn BookSpineUI, already gives you a valid reference to the class you just spawned, Casting to it again is unnecessary.
You use Cast to move from a parent class to a child class. eg: “GetAllActorsOfClass: Actor” Cast “Actor” to “ChildActor”. And it’ll succedd if ChildActor is in fact a child of the Actor Class.
Get the actor, get its widget component (your was called BookTitleWidget), get the generic widget object, cast to the actual widget class, get its text variable, set the new text.
so, with the “Exposed on Spawn” Variable, whenever you spawn that class the Title variable will show up there, and you won’t need to do anything else outside the class:
And normally you would update this sort of stuff in the constructor, but the widget doesn’t exist there yet, so you can’t access it until post begin play.