Exemplo n.º 1
0
            private void    DrawElement(Rect r, int index, bool isActive, bool isFocused)
            {
                r.width -= 30F;
                r.x     += 30F;
                EditorGUI.BeginChangeCheck();
                ProfilesManager.profiles[index].name = EditorGUI.TextField(r, ProfilesManager.profiles[index].name);
                if (EditorGUI.EndChangeCheck() == true)
                {
                    ProfilesManager.Save();
                }
                r.x -= 30;

                r.width = 30F;
                if (GUI.Button(r, ">") == true)
                {
                    ProfilesManager.SwitchFavorite(index);

                    if (ProfilesManager.SetProfile != null)
                    {
                        ProfilesManager.SetProfile();
                    }

                    InternalEditorUtility.RepaintAllViews();
                    this.editorWindow.Close();
                }
            }
Exemplo n.º 2
0
        private static void     SwitchFavorite(int i)
        {
            ProfilesManager.current = Mathf.Clamp(i, 0, ProfilesManager.profiles.Count - 1);
            EditorPrefs.SetInt(ProfilesManager.CurrentProfilePrefKey, ProfilesManager.current);

            if (ProfilesManager.SetProfile != null)
            {
                ProfilesManager.SetProfile();
            }
        }
Exemplo n.º 3
0
        public static void      Save()
        {
            EditorPrefs.SetInt(ProfilesManager.CurrentProfilePrefKey, ProfilesManager.current);
            EditorPrefs.SetString(ProfilesManager.ProfilesPrefKey, Convert.ToBase64String(Utility.SerializeField(ProfilesManager.profiles)));

            if (ProfilesManager.SetProfile != null)
            {
                ProfilesManager.SetProfile();
            }
        }
Exemplo n.º 4
0
        static ProfilesManager()
        {
            EditorApplication.delayCall += () =>
            {
                try
                {
                    string profilesPref = EditorPrefs.GetString(ProfilesManager.ProfilesPrefKey);

                    if (string.IsNullOrEmpty(profilesPref) == false)
                    {
                        ProfilesManager.profiles = Utility.DeserializeField <List <Profile> >(Convert.FromBase64String(profilesPref));
                    }
                }
                catch (Exception ex)
                {
                    InternalNGDebug.LogException(ex);
                }

                if (ProfilesManager.profiles == null)
                {
                    ProfilesManager.profiles = new List <Profile>();
                }

                if (ProfilesManager.profiles.Count == 0)
                {
                    ProfilesManager.profiles.Add(new Profile()
                    {
                        name = "Profile 1"
                    });
                }

                ProfilesManager.current = Mathf.Clamp(EditorPrefs.GetInt(ProfilesManager.CurrentProfilePrefKey), 0, ProfilesManager.profiles.Count - 1);

                ProfilesManager.Profile.outputPath       = ProfilesManager.Profile.outputPath ?? string.Empty;
                ProfilesManager.Profile.outputEditorPath = ProfilesManager.Profile.outputEditorPath ?? string.Empty;

                if (ProfilesManager.SetProfile != null)
                {
                    ProfilesManager.SetProfile();
                }

                InternalEditorUtility.RepaintAllViews();
            };
        }