rewriting a presets variables at runtime and assigning to a state?

DankP3

Active member
To avoid having mutliple (hundreds) of states on my viewtype, i was wanting to scatter presets around the scene and use these to populate the values on the preset used in the viewtype. I was able to scatter them and write their values to a single PersistablePreset in the project, but i failed in appying this preset to the state in the ViewType (changing the preset is insufficient presumably because it is cached or similar, sorry for ignorance).

I assume this is possible, could you please point me in the direction of how to update the preset on a state or reload it entirely from file (I dont even need to change the preset if i can reload it)?

In its simplest term, if i have one or a few states on the viewtype and wish to repeatedly load a different preset on demand for game area specific into one of those states...

Thanks,
 
For the most efficiency when the preset loads it creates a delegate and caches that value. When the state is activated it calls Preset.ApplyValue. The value is retrieved within Preset.UpdateValue using the get function which is created based off of the property.

It may require some refactoring in order to get what you are going for since the preset system wasn't designed with this in mind. If you want to have a go at it when you want to change the values you will need to call UpdateValue on the preset and then have the getter function return your new value.
 
To expand on that, if you want to adjust the preset values at runtime the easiest is probably to just modify the property on the ViewType directly instead of dealing with the state system. The end result would be the same and you wouldn't have to add a middle layer with the state system.
 
Just for updating on this. I ended up using a ScriptableObject that was shared by the ViewType and all the world locations and changing the values on that So when the player entered the new areas, using the state system to update the ViewType values. It seems robust.
 
I am facing the same problem here. I want to load settings from remote server, then apply those settings to a State Preset e.g. Attribute decrease rate, etc. Any suggested ideas on how to do it?
 
The preset system doesn't support runtime creation. For that situation you will need to set the property values through your own system and not through the state system.
 
Top