Esempio n. 1
0
        private void Load()
        {
            if (File.Exists(FilePath))
            {
                StorageData data = JsonUtility.FromJson <StorageData>(File.ReadAllText(FilePath));

                if (data == null || data.variables == null)
                {
                    Debug.LogWarningFormat(this, "Saved data found but not loaded. Format change?");
                    return;
                }

                if (data.variables.Length != m_SavedVariables.Length)
                {
                    Debug.LogErrorFormat(this, "Saved data and variable counts don't match!");
                    return;
                }

                for (int i = 0; i < data.variables.Length; i++)
                {
                    BaseGameVariable variable     = m_SavedVariables[i];
                    VariableData     variableData = data.variables[i];
                    variableData.Load(variable);
                }
            }
        }
Esempio n. 2
0
 private void Subscribe()
 {
     for (int i = 0; i < m_SavedVariables.Length; i++)
     {
         BaseGameVariable gameVariable = m_SavedVariables[i];
         gameVariable.GenericEvent += OnVariableChanged;
     }
 }
Esempio n. 3
0
 public void Load(BaseGameVariable variable)
 {
     variable.ValueString = value;
 }
Esempio n. 4
0
 public VariableData(BaseGameVariable variable)
 {
     name  = variable.Name;
     value = variable.ValueString;
 }