Get Class Defaults for overridden variables

Hi :slight_smile: Let’s imagine this in pseudo language:

BP_MyClassOriginal
-int32 MyVar = 10 (i mean default value set in Class Defaults editor);

BP_MyClassDerivedFromOriginal
-int32 MyVar = 20 (i mean default value set in Class Defaults editor);
-int32 MyNewVar;

Now, in runtime, i want to know default value of variable MyVar for instance of BP_MyClassDerivedFromOriginal. But if i will call GetClassDefaults in blueprint for this class, i will only see MyNewVar value.

What is the right way to know default value of MyVar in BP_MyClassDerivedFromOriginal class? Thank you.

I’m also interested in this

You can go back in class inherence tree by using this function in UClass:

Hi,
I have the similar problem.

I declare a variable with config specifier, and want to get the overridden default value from its child class without being spawned.

Some code:

UCLASS(config = MyConfig)
class MY_API AMyBase : public AActor
{
	...
	
	UPROPERTY(Config)
	float fVarA;
	...
}


UCLASS(config = MyConfig)
class MYGAME_API AMyChild : public AMyBase
{
	...
	...
}

DefaultMyConfig.ini

[/Script/MYGAME_API.MyBase]
fVarA=1.f

[/Script/MYGAME_API.MyChild]
fVarA=2.f

Try to get the default value of fVarA by using its DefaultObject.

AMyChild * MyChildDefaultObject = MyChildClass->GetDefaultObject<AMyChild>();
float defaultFVarA= MyChildDefaultObject ->fVarA;

However, every time I print this value, it always be 0.f.
In this case, I hope it be 2.f.

How to figure out this?
Any answer will be appreciated.