Changing editable UPROPERTY variable to be a Config variable is ignored

Repro steps:

1 Create a UPROPERTY variable in code:

UPROPERTY(Category = "My Actor", EditDefaultsOnly, BlueprintReadOnly)
float myFloatVar;

2 Open a blueprint w/ that variable in the editor and set/save a new value for it.

3 Change UPROPERTY variable to config variable type

UPROPERTY(Config)
float myFloatVar;

4 Try to adjust the value in Config file.

Notice that the blueprint you edited before making the variable a Config variable will not take new values set in the Config file. Value is stuck at the last value you saved on that specific blueprint. My work around is just to rename the variable, but…gross.

I don’t think this is a bug , actor defaults have higher priority then config, aspecially if it’a only a child of that class. Also can you specify what you adding here “Open the actor w/ that variable in the editor and set/save a new value for that variable.” Blueprint defaults based of C++ class or varable of actor on the level?

You can do manual config load with LoadConfig()

You must let your class know where to get its Config values from. In your header file add a Config property to your UCLASS(Config = Game) if you’ve saved your config properties in DefaultGame.ini file. Next, in DefaultGame.ini file, you must also explicitly say to what class these values refer to (Or in other words, where your UCLASS should read its variables from). Something similar to following lines should be added to your .ini file (See that the configurable UPROPERTY members are initialized as a Key=Value right beneath the class address).

[/Script/YourProject.YourClassName]

SomeFloatVariable=1.0

Hope this helps.

1 Like

IMHO, it’s a bug b/c I’m explicitly not exposing the value in the Blueprint anymore. If that’s the case, it should ignore any value set in the blueprint cause there’s no way to adjust it.

The value is read properly for other blueprints. Check my specific repro steps for the difference here.

Okay, I believe I now get what your problem is. Sorry, the question was not clear at first.

So you initially created a Blueprint exposable variable and then changed its value in the editor, later you decided to make it a UPROPERTY(Config) instead and now the Editor doesn’t update to the new value which is set in the .ini file? is that correct? Well, I’ve personally never faced such problem before but maybe the following approach can help you fix this issue:

Change it back to EditDefaultsOnly and make it blueprint exposable. Compile and go to your file, find the variable in the details panel, click that yellow arrow in front of it to reset to its original value. Compile and go back to your C++, make it Config and try again and see if it now reads the Config value from .ini file.

I understand that in your case you’re changing the UPROPERTY and do not expose it to blueprints only. Maybe it’s a bug that UE keeps that variable in its memory and persists on using the Blueprint value. Anyways, as I’ve also noticed, in Unreal once you create a blueprint based on your C++ class, and change the exposable variables inside that blueprint, Unreal will persist on using that changed value and will not read the C++ value anymore even if you go back to your code and change its default value in C++. For each of these variables that you changed their value in BP, you would have to manually reset them by clicking on that yellow arrow.

Hope this can help you resolve your issue.

Yeah, not a bad work around there either. I find renaming when I’m switching to a Config is the safest way to make sure everything is cleared across the board. But like I said…kinda gross.

I’m not sure if renaming is a good practice because depending on how big your code is, you might have to change every single reference to it in your code and that itself is a big trouble!

All in all, you now know how to fix this and I’m sure you will adopt the approach that suits you best.

Good luck!

there is other big problem about it
the is about config variables my config variables which have non English names not load with their default value that i write in config files like DefaultGame.ini however which variables have English name load aright their string value !!!

I was able to bypass this. You need to remove old value from .uasset file.

  1. Rename this property
  2. Load editor and open this asset
  3. Save this asset this would clean up value of property from .uasset binary file
    a. If save button is inactive – change any existing property. Then save it. Revert value and save againg.
  4. Rename UPROPERY back in C++

Now old value would be cleared from .uasset and value would be loaded from .INI file

It’s bad idea to use non english names inside C++ and for “Internal Name” insude UE.

You could use “DisplayName” value inside UPROPERTY macro to define name visible in editor.