Esempio n. 1
0
        /// <summary>
        /// Update the Data values with the Items values
        /// </summary>
        public virtual void UpdateData(SelectorManager manager)
        {
            for (int i = 0; i < manager.Editor.Items.Count; i++)            //Save the Locked Elements
            {
                Save.Locked[i]      = manager.Editor.Items[i].Locked;
                Save.ItemsAmount[i] = manager.Editor.Items[i].Amount;

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

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

            Save.FocusedItem = manager.Controller.FocusedItemIndex;

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


#if UNITY_EDITOR
            UnityEditor.EditorUtility.SetDirty(this);
#endif
        }
Esempio n. 2
0
        /// <summary>
        /// Update the Data values with the Items values
        /// </summary>
        public virtual void UpdateData(SelectorManager manager)
        {
            for (int i = 0; i < manager.Editor.Items.Count; i++)            //Save the Locked Elements
            {
                Save.Locked[i]      = manager.Editor.Items[i].Locked;
                Save.ItemsAmount[i] = manager.Editor.Items[i].Amount;

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

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

            Save.FocusedItem = manager.Controller.FocusedItemIndex;

            SaveDataPlayerPrefs();

            manager.OnDataChanged.Invoke();

#if UNITY_EDITOR
            UnityEditor.EditorUtility.SetDirty(this);
#endif
        }
Esempio n. 3
0
        /// <summary>
        /// Restore the items values from the Restore Data
        /// </summary>
        public virtual void RestoreData(SelectorManager manager)
        {
            LoadDataPlayerPref();

            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];
                }
            }


            SaveDataPlayerPrefs();

            UpdateItems(manager);                                       //Update the Items from the Data
            manager.OnDataChanged.Invoke();

#if UNITY_EDITOR
            UnityEditor.EditorUtility.SetDirty(this);
#endif
        }
        private void OnEnable()
        {
            M                       = (SelectorManager)target;
            script                  = MonoScript.FromMonoBehaviour((MonoBehaviour)target);
            enableSelector          = serializedObject.FindProperty("enableSelector");
            DontDestroy             = serializedObject.FindProperty("DontDestroy");
            ItemSelected            = serializedObject.FindProperty("ItemSelected");
            OriginalItemSelected    = serializedObject.FindProperty("OriginalItemSelected");
            InstantiateItems        = serializedObject.FindProperty("InstantiateItems");
            SpawnPoint              = serializedObject.FindProperty("SpawnPoint");
            RemoveLast              = serializedObject.FindProperty("RemoveLast");
            DontDestroySelectedItem = serializedObject.FindProperty("DontDestroySelectedItem");
            ShowAnims               = serializedObject.FindProperty("ShowAnims");
            Target                  = serializedObject.FindProperty("Target");
            EnterAnimation          = serializedObject.FindProperty("EnterAnimation");
            ExitAnimation           = serializedObject.FindProperty("ExitAnimation");
            FocusItemAnim           = serializedObject.FindProperty("FocusItemAnim");
            SubmitItemAnim          = serializedObject.FindProperty("SubmitItemAnim");
            Data                    = serializedObject.FindProperty("Data");
            OnSelected              = serializedObject.FindProperty("OnSelected");
            OnOpen                  = serializedObject.FindProperty("OnOpen");
            OnClosed                = serializedObject.FindProperty("OnClosed");
            OnDataChanged           = serializedObject.FindProperty("OnDataChanged");

            OnItemFocused = serializedObject.FindProperty("OnItemFocused");

            ShowEvents = serializedObject.FindProperty("ShowEvents");
        }
Esempio n. 5
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
        }
Esempio n. 6
0
        /// <summary>
        /// Update the Items values with the Data Values.
        /// </summary>
        public virtual void UpdateItems(SelectorManager manager)
        {
            if (!manager.Editor)
            {
                return;
            }

            //if (manager.Editor.Items.Count != Save.Locked.Length)
            if (manager.Editor.Items.Count != Save.Locked.Count)
            {
                Debug.LogWarning("Please, on the Selector Manager Press 'Save initial Data'\nYou have add or remove items and the current Items ammount and the Items amount in the Data File are not the same");
                return;
            }

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

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

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

            manager.Controller.FocusedItemIndex = Save.FocusedItem;

            manager.OnDataChanged.Invoke();

#if UNITY_EDITOR
            UnityEditor.EditorUtility.SetDirty(this);
#endif
        }
 private void OnEnable()
 {
     M      = (SelectorManager)target;
     script = MonoScript.FromMonoBehaviour((SelectorManager)target);
 }
Esempio n. 8
0
        /// <summary>
        /// Saves the Initial Data of a Selector Manager
        /// </summary>
        public virtual void SetDefaultData(SelectorManager manager)
        {
            Save.RestoreCoins = Save.Coins;                                       //Save the RestoreCoins to the Current Coins

            Save.RestoreLocked = new List <bool>();
            Save.Locked        = new List <bool>();

            Save.RestoreItemsAmount = new List <int>();
            Save.ItemsAmount        = new List <int>();

            Save.UseMaterialChanger = Save.UseActiveMesh = false;
            Save.FocusedItem        = manager.Controller.FocusedItemIndex;

            Save.ActiveMeshIndex        = null;
            Save.RestoreActiveMeshIndex = null;
            Save.MaterialIndex          = null;
            Save.RestoreMaterialIndex   = null;

            if (manager.Editor.Items != null && manager.Editor.Items.Count > 1)         //Check for Material Changer and Active Mesh
            {
                if (manager.Editor.Items[0].MatChanger != null)
                {
                    Save.UseMaterialChanger   = true;
                    Save.RestoreMaterialIndex = new List <string>();
                    Save.MaterialIndex        = new List <string>();
                }

                if (manager.Editor.Items[0].ActiveMesh != null)
                {
                    Save.UseActiveMesh          = true;
                    Save.RestoreActiveMeshIndex = new List <string>();
                    Save.ActiveMeshIndex        = new List <string>();
                }
            }

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

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

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

            Update_Current_Data_from_Restore();


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

                PlayerPrefs.SetString(PlayerPrefKey, MalbersTools.Serialize <SelectorSave>(Save));
                Debug.Log("Default Data saved on PlayerPref using the key: '" + PlayerPrefKey + "'\n" + MalbersTools.Serialize <SelectorSave>(Save));
            }



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