How can I reset to default blueprint my variables?

Hello, I want to reset my variables in code C++ as default blueprint like UE4 Editor do when you press the yellow arrow in editor

281240-untitled4.png

Does anyone know how can I do it?

You probably can’t do it built-in for in-game, as it’s Editor code, see FPropertyValueImpl::ResetToDefault() and FPropertyNode::GetDefaultValueAsStringForObject for example.

You can always of course write your own logic to do it, depending on what do you want to achieve exactly.

I just want it for Editor Widget Code (not in-game), so is there any way to do it or what does Unreal Engine 4 inside to do that?

Well if you are planning to do an Editor Utility Widget, I’m sure there isn’t anything like this built-in to Blueprints.

As for C++, these codes seem to be quite specific to the Properties (and most of them are probably private / public anyways). You can dig the engine source if you can accidentally find anything useful that is both exported and accessible, but it seems unlikely for me based on the functions I have mentioned above.

I just do it getting the actor like this

AActor* blueprintActor = cppActor->GetClass()->GetDefaultObject<AActor>();

and set the values directly to blueprintActor, the problem is it is not set as dirty so the data is not saved when I close and open the editor, do you know something that I can do to set this to dirty?

I believe you can use blueprintActor->MarkPackageDirty().

It works! Thanks you so much!