How to reference a UObject in scene and modify its properties at runtime in C++?
I have custom classes I made and I'm doing all the logic in C++, no blueprints. I can't figure out how to get the components on an object Unity3D style and modify certain properties like visibility or material color. UMG seems to be its own thing too because I have no clue how to reference anything in there in a custom Pawn class at runtime. Would I need a UOject or UClass variable to do this? The documentation isn't clear enough for me to understand.
Pseudo code, I basically want to do this...
The Unity way would be
And that's basically what I'm trying to do.
In Unreal it's the same as in Unity.
You have a public Variable which can be edited in Editor.
In Unreal you have to specify the visibility of a Variable through the UPROPERTY macro.
You can reference "ObjectToReference" by dragging the Object which implements DoAThing into the Scene and filling "Object To Reference" in the Details Panel.
But be aware that UObject don't have any Components except they are AActor. So if you just want a reference to an actual Actor use instead of UObject* AActor*
I hope I could help you :)
answered Jul 06 '16 at 08:18 AM
I know two way to reference scene objects in C++ right now:
Hope this help. Good luck! Don't surrender, I'm also quite new in Unreal Engine and I know how hard it is to get into.
answered Jul 06 '16 at 08:16 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here