Download

How to store array variables in config file?

I recently ran into a bug where upon a crash, my default variables for an array keep being reset. It’s getting annoying and it isn’t going to get better with scale. The variable is an array of static meshes that can be used for the actor. I’d like to store these in a config file instead as an option until this bug is resolved.

Does anyone know how to do this?

I only really know where the config goes in defaultEngine.ini and to set it up like this, but the representation of an array in a config file is unknown to me. Can anyone help?:
[Game/Hexagons/TileClasses/hex_standard_basic.hex_standard_basic_C]
componentMesh=Game/Hexagons/Meshes/hex_Standard_tile.fbx

Make an UObject and on its declaration add “config = Game” (or any other .ini name);
On your TArray declararion add “config” to its UFUNCTION() macro.
Unreal will always load CDO with default values from that ini; then just get the values using GetMutableDefault<UYourUObject>() function.

Oh, I mean, in C++…

can this be done without C++ via blueprint? For instance, how would I represent the array in the config file? I know how to set an integer variable in int config as Myvariable=2 but I don’t know how to represent an array of Meshes.

The thing I told there was to add ini values automatically; doing that you won’t edit any ini by hand, Unreal will build the array itself line by line and read it back when game loads. I don’t think you can do that with blueprints, no.

Editing by hand is easy and the intention here.

For instance:

This loads array item 1:
UniqueComponentMesh=StaticMesh ‘/Game/hexagons/Meshes/hex_standard_tile_20CM.hex_standard_tile_20CM’

But I can’t figure out the syntax to load more than 1 array item into UniqueComponentMesh.
StaticMesh’/Game/hexagons/Meshes/hex_component_1.hex_component_1’)

I believe you have each on separate lines with “+” before it, so for example a mesh array called Meshes with two elements would be:

+Meshes=StaticMesh’/Game/StarterContent/Shapes/Shape_Cylinder.Shape_Cylinder’
+Meshes=StaticMesh’/Game/StarterContent/Shapes/Shape_Cone.Shape_Cone’

Also, if you create the array in blueprints first, then right click and copy, you can paste it somewhere so you don’t have type out all the paths individuallt.

**PERFECT
**
This is what ended up working for me.

UniqueComponentMesh=StaticMesh’/Game/hexagons/Meshes/hex_standard_tile_20CM.hex_standard_tile_20CM’
+UniqueComponentMesh=StaticMesh’/Game/hexagons/Meshes/hex_component_1.hex_component_1’
+UniqueComponentMesh=StaticMesh’/Game/hexagons/Meshes/hex_component_2.hex_component_2’
+UniqueComponentMesh=StaticMesh’/Game/hexagons/Meshes/hex_component_3.hex_component_3’
+UniqueComponentMesh=StaticMesh’/Game/hexagons/Meshes/hex_component_4.hex_component_4’
+UniqueComponentMesh=StaticMesh’/Game/hexagons/Meshes/hex_component_5.hex_component_5’
+UniqueComponentMesh=StaticMesh’/Game/hexagons/Meshes/hex_component_6.hex_component_6’
+UniqueComponentMesh=StaticMesh’/Game/hexagons/Meshes/hex_component_7.hex_component_7’
+UniqueComponentMesh=StaticMesh’/Game/hexagons/Meshes/hex_component_8.hex_component_8’

Does anyone know in what order the config files load compared to the rest of the level?

You don’t have to use the “+” sign though;

I took a look at one auto generated ini Unreal makes for my plugin and it just look like this:

I had tried that without the + but the array item at index 0 was just overwritten by the next one. Your plugin may treat the config differently.

lol so weird; it should be the same for both Blueprints or C++ classes :eek:

Excuse me for replaying the old post, but I found that
in Saved/Config/XX/YY.ini, you don’t have to add ‘+’,
while in Proj/Config/DefaultYY.ini, you have to add ‘+’