Beispiel #1
0
 public virtual void LoadDataPlayerPref()
 {
     if (usePlayerPref && PlayerPrefs.HasKey(PlayerPrefKey))
     {
         Save = MalbersTools.Deserialize <SelectorSave>(PlayerPrefs.GetString(PlayerPrefKey));            //Get the Data from the Player Preff.
     }
 }
Beispiel #2
0
        /// <summary>
        /// Restore the items values from the Restore Data
        /// </summary>
        public virtual void RestoreData(SelectorManager manager)
        {
            if (usePlayerPref && PlayerPrefs.HasKey(PlayerPrefKey))
            {
                Save = MalbersTools.Deserialize <SelectorSave>(PlayerPrefs.GetString(PlayerPrefKey));
            }


            Update_Current_Data_from_Restore();

            for (int i = 0; i < manager.Editor.Items.Count; i++)            //Save the Locked Elements
            {
                manager.Editor.Items[i].Locked = Save.RestoreLocked[i];
                manager.Editor.Items[i].Amount = Save.RestoreItemsAmount[i];


                if (Save.UseMaterialChanger && manager.Editor.Items[i].MatChanger)
                {
                    manager.Editor.Items[i].MatChanger.AllIndex = Save.RestoreMaterialIndex[i];
                }

                if (Save.UseActiveMesh && manager.Editor.Items[i].ActiveMesh)
                {
                    manager.Editor.Items[i].ActiveMesh.AllIndex = Save.RestoreActiveMeshIndex[i];
                }
            }



            if (usePlayerPref)
            {
                if (PlayerPrefs.HasKey(PlayerPrefKey))
                {
                    PlayerPrefs.DeleteKey(PlayerPrefKey);
                }

                PlayerPrefs.SetString(PlayerPrefKey, MalbersTools.Serialize <SelectorSave>(Save));
            }

            UpdateItems(manager);                                       //Update the Items from the Data

#if UNITY_EDITOR
            UnityEditor.EditorUtility.SetDirty(this);
#endif
        }