I tested the possibility to use the ScriptableObject to Store Game settings.
The default values Stored in asset.
[CreateAssetMenu(fileName ="GameSettingsSO",menuName = "SoundAndEffects/GameSettingsSO")]
public class GameSettingsSO : ScriptableObject
{
[Header("Game Options")]
[SerializeField] private ComplexitySO _complexityGame;
[SerializeField] private PlayMode _usedPlayMode;
[Header("Audio Options")]
[SerializeField] private float _masterVolume;
[SerializeField] private float _musicVolume;
[SerializeField] private float _effectVolume;
[SerializeField] private SequenceType _musicSequenceType;
public override string ToString() => JsonUtility.ToJson(this);
public PlayMode UsedPlayMode => _usedPlayMode;
public ComplexitySO ComplexityGame => _complexityGame;
}
The Changed Settings saved to disk through JSON serialization as string
JsonUtility.ToJson(storeScriptableObjectData);
Was detected strange behavior:
EDIT see note at next post
When I store in Play mode in Editor the field â_complexityGameâ serialized like as :{âinstanceIDâ:18942}
{"_complexityGame":{"instanceID":18942},"_usedPlayMode":2,"_notCopyToGlobal":true,"_globalDefaultTopList":false,"_masterVolume":1.0,"_musicVolume":2.0,"_effectVolume":3.0,"_musicSequenceType":1}
When I store in Play mode in Build the field â_complexityGameâ serialized like as :{âm_FileIDâ:2154,âm_PathIDâ:0}
{"_complexityGame":{"m_FileID":2154,"m_PathID":0},"_usedPlayMode":2,"_notCopyToGlobal":true,"_globalDefaultTopList":false,"_masterVolume":1.0,"_musicVolume":2.0,"_effectVolume":3.0,"_musicSequenceType":1}
Every time it was contained the same value
I can understand the reason of that, and for save setting itâs not a big problem (you may not transfer this to build).
But if you try to save something in processing of developing (as JSON) and how it can restore after in build, in case if it will not primitive values?