Example #1
0
    public void SaveComponent <T1, T2>(string name, string value, string sceneName)
        where T1 : ISave <T2>
    {
        if (string.IsNullOrEmpty(name))
        {
            return;
        }
        string ISaveName     = typeof(T1).Name;
        string componentName = typeof(T2).Name;

        SceneData sceneData = GameSaveUtility.GetSceneData(sceneName);

        if (null == sceneData)
        {
            GameSaveUtility.AddSceneData(sceneName);
        }
        SaveObject saveObject = GameSaveUtility.GetSaveObjectData(name, sceneName);

        if (null == saveObject)
        {
            saveObject = GameSaveUtility.AddSaveObjectData(name, sceneName);
        }

        if (saveObject.SetValues.CheckEmpty())
        {
            saveObject.SetValues = new Dictionary <string, Dictionary <string, SetValue> >();
        }

        Dictionary <string, SetValue> setValues;

        if (saveObject.SetValues.ContainsKey(componentName))
        {
            setValues = saveObject.SetValues[componentName];
        }
        else
        {
            setValues = new Dictionary <string, SetValue>();
            saveObject.SetValues.Add(componentName, setValues);
        }

        SetValue setValue = new SetValue
        {
            FunOpera = ISaveName,
            Value    = value
        };

        if (setValues.ContainsKey(ISaveName))
        {
            setValues[ISaveName] = setValue;
        }
        else
        {
            setValues.Add(ISaveName, setValue);
        }
    }