Exemple #1
0
        /// <summary>
        /// Set up persistence
        /// </summary>
        protected void LoadData()
        {
            m_DataSaver = new JsonSaver <TDataStore>(k_SavedGameFile);

            try
            {
                if (!m_DataSaver.Load(out m_DataStore))
                {
                    m_DataStore = new TDataStore();
                    SaveData();
                }
            }
            catch (Exception)
            {
                Debug.Log("Failed to load data, resetting");
                m_DataStore = new TDataStore();
                SaveData();
            }
        }
Exemple #2
0
        /// <summary>
        /// Set up persistence
        /// </summary>
        protected void LoadData()
        {
            // If it is in Unity Editor use the standard JSON (human readable for debugging) otherwise encrypt it for deployed version
#if UNITY_EDITOR
            m_DataSaver = new JsonSaver <TDataStore>(k_SavedGameFile);
#else
            m_DataSaver = new EncryptedJsonSaver <TDataStore>(k_SavedGameFile);
#endif

            try
            {
                if (!m_DataSaver.Load(out m_DataStore))
                {
                    m_DataStore = new TDataStore();
                    SaveData();
                }
            }
            catch (Exception)
            {
                Debug.Log("Failed to load data, resetting");
                m_DataStore = new TDataStore();
                SaveData();
            }
        }