Download

C++ parent class cannot read Blueprint modified variables

Hi there, I’m working on a pesonal project. And I added a C++ class based on USceneComponent. There are some **protected **access variables which will be used in constructor function. Then, I created a Blueprint derived from this C++ class. I can modify these protected variables and save. But when I add this component Blueprint into game, the C++ constructor function can’t read the saved variables of Blueprint class.

What I want to do is using Blueprints as classes preset. I can easily create a instance with specified parameters. Does anyone know how to make the C++ constructor read Blueprints value successfully? Or is there some other approach?

Thanks a lot.

I’ve solved this question by self. Actually, the properties of C++ class will be assigned the specified value after constructor. Also, as a parent class, its constructor will be invoked before the one of derived class. As a result, there is no way to access the assigned value in Blueprint class in the constructor of parent class.

I solved this problem with PostInitProperties() function. This function will be invoked after all properties are assigned values. Get variable value is a piece of cake in this function.

Hope this is help for those people have encountered the same problem.