Beispiel #1
0
 public static T LoadScriptData <T> (string stringData) where T : RememberData
 {
     if (SaveSystem.GetSaveMethod() == SaveMethod.XML)
     {
         return((T)Serializer.DeserializeObjectXML <T> (stringData));
     }
     else
     {
         return((T)Serializer.DeserializeRememberData <T> (stringData));
     }
 }
Beispiel #2
0
        public static T LoadScriptData <T> (string stringData) where T : RememberData
        {
            if (SaveSystem.GetSaveMethod() == SaveMethod.XML)
            {
                // iOS fix: Sending to wrong type causes error, so pre-empt by checking type
                string typeName = typeof(T).ToString().Replace("AC.", "");

                if (stringData.Contains(typeName))
                {
                    return((T)Serializer.DeserializeObjectXML <T> (stringData));
                }
            }
            else
            {
                return((T)Serializer.DeserializeRememberData <T> (stringData));
            }

            return(null);
        }
Beispiel #3
0
        public static OptionsData LoadPrefsFromID(int ID, bool showLog = false, bool doSave = true)
        {
            if (PlayerPrefs.HasKey(GetPrefKeyName(ID)))
            {
                string optionsSerialized = PlayerPrefs.GetString(GetPrefKeyName(ID));

                if (optionsSerialized != null && optionsSerialized.Length > 0)
                {
                    bool isXML = optionsSerialized.Contains("xml version");
                    if (SaveSystem.GetSaveMethod() == SaveMethod.XML && isXML)
                    {
                        if (showLog)
                        {
                            Debug.Log("PlayerPrefs Key '" + GetPrefKeyName(ID) + "' loaded");
                        }
                        return((OptionsData)Serializer.DeserializeObjectXML <OptionsData> (optionsSerialized));
                    }
                    else if (SaveSystem.GetSaveMethod() == SaveMethod.Binary && !isXML)
                    {
                        if (showLog)
                        {
                            Debug.Log("PlayerPrefs Key '" + GetPrefKeyName(ID) + "' loaded");
                        }
                        return((OptionsData)Serializer.DeserializeObjectBinary <OptionsData> (optionsSerialized));
                    }
                }
            }

            // No data exists, so create new
            OptionsData _optionsData = new OptionsData(KickStarter.settingsManager.defaultLanguage, KickStarter.settingsManager.defaultShowSubtitles, KickStarter.settingsManager.defaultSfxVolume, KickStarter.settingsManager.defaultMusicVolume, KickStarter.settingsManager.defaultSpeechVolume, ID);

            if (doSave)
            {
                optionsData = _optionsData;
                SavePrefs();
            }

            return(_optionsData);
        }