Viewing C++ Parameters in Editor

There are many situations where I want to set a material or a mesh or something in the editor as a parameter on an actor and apply it dynamically in c++. When I try to use the parameter in the constructor in c++ I get an error because it is only available in begin play. But applying the parameter in begin play doesn’t let me see the change in the editor unless I am simulating the game.

Is there a way around this? I assume its just sort of something you have to deal with if you want to do stuff dynamically in code but maybe i’m missing something?

Hey ryandlf-

You can override the OnConstruction() function of your actor class. This function is called anytime the actor is updated (either in the viewport or blueprints). The best option would be to create public variables in your code so that you can edit the parameter value without having to compile the code continuously.

Cheers

I’ve played with OnConstruction a bit and sort of gave up because I tend to do a lot of object creation in the constructor and I was having problems with just constant spawning. Thats on me though writing crap code haha. So OnConstruction is the best option? I’m not sure I understand the second part about public variables? Thats usually what I do. I create a variable in c++ and add a uproperty to it and then I set the variable usually with a class or a mesh or something in the editor and then I can access that stuff in c++. Is that what you meant?

Yes, that’s correct.