How to cast C++ variable to another Blueprint class
How to cast C++ variable to another Blueprint class?
I create C++ Actor with some calculation and put it to a scene. Let's name it CodedActor.
CodedActor contain some TArray as a result of some function.
I create blueprint widget with some menu. There is another class. Let's name it BlueprintMenuWidget.
How can I use variables (my TArray) from the CodedActor in the BlueprintMenuWidget?
I have some problems with the implementation due to different classes of objects. I believe, it's typical thing, however I can't find an answer.
Thanks in advance!
asked Mar 23 '17 at 01:38 PM in C++ Programming
Either your BlueprintMenuWidget has to have a reference to your CodedActor, or the other way around. If you have this reference in Blueprint (or pointer in C++) you can access all of the (public) members of the object.
So lets say you have a reference to your CodedActor in you BlueprintMenuWidget. You could do this by having the Actor create the widget. This ways the Actor can set the reference insinde of the Widget.
When the widget wants to access members of the CodedActor (your TArray in this case) it can just do so by using the reference that it has to the actor. If you declare the TArray like this in your actor:
You can just drag a node off of the reference to the actor in blueprint, type ArrayName, and voila you have your array.
answered Mar 23 '17 at 01:56 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here