示例#1
0
        protected virtual void  OnEnable()
        {
            Utility.RegisterWindow(this);
            Utility.RestoreIcon(this, NGSettingsWindow.TitleColor);

            if (NGSettingsWindow.sections.Count > 0)
            {
                this.workingSection = NGSettingsWindow.sections[0];
            }

            this.r        = new Rect(0F, 40F, NGSettingsWindow.SectionWidth, 0F);
            this.body     = new Rect(0F, 0F, NGSettingsWindow.SectionWidth, 0F);
            this.viewRect = new Rect();

            HQ.SettingsChanged     += this.Repaint;
            Undo.undoRedoPerformed += this.Repaint;

            EditorApplication.delayCall += () =>
            {
                // As crazy as it seems, we need 3 nested delayed calls. Because we need to ensure everybody is in the room to start the party.
                this.Focus(NGEditorPrefs.GetString(NGSettingsWindow.LastSectionPrefKey));
                this.Repaint();
            };

            this.wantsMouseMove = true;
        }
示例#2
0
        public override void    DirectSave(object instance, Type type, string path)
        {
            Vector2 value = (Vector2)instance;

            NGEditorPrefs.SetFloat(path + ".x", value.x);
            NGEditorPrefs.SetFloat(path + ".y", value.y);
        }
示例#3
0
文件: HQ.cs 项目: Hengle/clapotis
        public static void      CreateNGSettings(string path)
        {
            try
            {
                NGSettings asset = ScriptableObject.CreateInstance <NGSettings>();

                AssetDatabase.CreateAsset(asset, path);
                AssetDatabase.SaveAssets();

                NGEditorPrefs.SetString(Constants.ConfigPathKeyPref, path, true);

                HQ.SetSettings(asset);

                // Need to skip many frames before really writing the data. Don't know why it requires 2 frames.
                EditorApplication.delayCall += () =>
                {
                    EditorApplication.delayCall += () =>
                    {
                        HQ.InvalidateSettings();
                        AssetDatabase.SaveAssets();
                    };
                };
            }
            catch (Exception ex)
            {
                InternalNGDebug.LogException(ex);
                HQ.SetSettings(null);
            }
        }
示例#4
0
文件: HQ.cs 项目: Hengle/clapotis
        internal static void    SetStatsComplementary(string key, string value)
        {
            string        complementary = NGEditorPrefs.GetString(HQ.ComplementaryKeyPref);
            List <string> data          = new List <string>();
            bool          found         = false;

            if (string.IsNullOrEmpty(complementary) == false)
            {
                data.AddRange(complementary.Split(HQ.ComplementarySeparator));
            }

            for (int i = 0; i < data.Count; i++)
            {
                if (data[i].StartsWith(key + '=') == true)
                {
                    found = true;
                    if (string.IsNullOrEmpty(value) == true)
                    {
                        data.RemoveAt(i--);
                    }
                    else
                    {
                        data[i] = key + '=' + value;
                    }
                }
            }

            if (found == false)
            {
                data.Add(key + '=' + value);
            }

            NGEditorPrefs.SetString(HQ.ComplementaryKeyPref, string.Join(HQ.ComplementarySeparator.ToString(), data.ToArray()));
        }
示例#5
0
 public static string    GetString(string key, string defaultValue = "", bool perProject = false)
 {
     if (perProject == true)
     {
         key = NGEditorPrefs.GetPerProjectPrefix() + key;
     }
     return(EditorPrefs.GetString(key, defaultValue));
 }
示例#6
0
 public static void      DeleteKey(string key, bool perProject = false)
 {
     if (perProject == true)
     {
         key = NGEditorPrefs.GetPerProjectPrefix() + key;
     }
     EditorPrefs.DeleteKey(key);
 }
示例#7
0
文件: HQ.cs 项目: Hengle/clapotis
 private static void     ResetAssets()
 {
     if (HQ.settings == null)
     {
         NGEditorPrefs.DeleteKey(Constants.ConfigPathKeyPref, true);
         GUICallbackWindow.Open(() => HQ.LoadSharedNGSetting());
     }
 }
示例#8
0
		public override object	Fetch(object instance, Type type, string path)
		{
			Int64	result;

			if (Int64.TryParse(NGEditorPrefs.GetString(path), out result) == true)
				return result;
			return instance;
		}
示例#9
0
 public static bool      HasKey(string key, bool perProject = false)
 {
     if (perProject == true)
     {
         key = NGEditorPrefs.GetPerProjectPrefix() + key;
     }
     return(EditorPrefs.HasKey(key));
 }
示例#10
0
 public static float             GetFloat(string key, float defaultValue = 0F, bool perProject = false)
 {
     if (perProject == true)
     {
         key = NGEditorPrefs.GetPerProjectPrefix() + key;
     }
     return(EditorPrefs.GetFloat(key, defaultValue));
 }
示例#11
0
 public static void              SetString(string key, string value, bool perProject = false)
 {
     if (perProject == true)
     {
         key = NGEditorPrefs.GetPerProjectPrefix() + key;
     }
     EditorPrefs.SetString(key, value);
 }
示例#12
0
 public static int               GetInt(string key, int defaultValue = 0, bool perProject = false)
 {
     if (perProject == true)
     {
         key = NGEditorPrefs.GetPerProjectPrefix() + key;
     }
     return(EditorPrefs.GetInt(key, defaultValue));
 }
示例#13
0
 public static bool              GetBool(string key, bool defaultValue = false, bool perProject = false)
 {
     if (perProject == true)
     {
         key = NGEditorPrefs.GetPerProjectPrefix() + key;
     }
     return(EditorPrefs.GetBool(key, defaultValue));
 }
示例#14
0
        public override void    DirectSave(object instance, Type type, string path)
        {
            Color value = (Color)instance;

            NGEditorPrefs.SetFloat(path + ".r", value.r);
            NGEditorPrefs.SetFloat(path + ".g", value.g);
            NGEditorPrefs.SetFloat(path + ".b", value.b);
            NGEditorPrefs.SetFloat(path + ".a", value.a);
        }
示例#15
0
        public override void    DirectSave(object instance, Type type, string path)
        {
            Rect value = (Rect)instance;

            NGEditorPrefs.SetFloat(path + ".x", value.x);
            NGEditorPrefs.SetFloat(path + ".y", value.y);
            NGEditorPrefs.SetFloat(path + ".w", value.width);
            NGEditorPrefs.SetFloat(path + ".h", value.height);
        }
示例#16
0
        public override void    DirectSave(object instance, Type type, string path)
        {
            Quaternion value = (Quaternion)instance;

            NGEditorPrefs.SetFloat(path + ".x", value.x);
            NGEditorPrefs.SetFloat(path + ".y", value.y);
            NGEditorPrefs.SetFloat(path + ".z", value.z);
            NGEditorPrefs.SetFloat(path + ".w", value.w);
        }
示例#17
0
        public override object  Fetch(object instance, Type type, string path)
        {
            Vector2 value = (Vector2)instance;

            value.x = NGEditorPrefs.GetFloat(path + ".x", value.x);
            value.y = NGEditorPrefs.GetFloat(path + ".y", value.y);

            return(value);
        }
示例#18
0
        public override object  Fetch(object instance, Type type, string path)
        {
            Decimal result;

            if (Decimal.TryParse(NGEditorPrefs.GetString(path), out result) == true)
            {
                return(result);
            }
            return(instance);
        }
示例#19
0
        public override object  Fetch(object instance, Type type, string path)
        {
            Rect value = (Rect)instance;

            value.x      = NGEditorPrefs.GetFloat(path + ".x", value.x);
            value.y      = NGEditorPrefs.GetFloat(path + ".y", value.y);
            value.width  = NGEditorPrefs.GetFloat(path + ".w", value.width);
            value.height = NGEditorPrefs.GetFloat(path + ".h", value.height);

            return(value);
        }
示例#20
0
 public void     Save()
 {
     if (this.disabledTips.Count > 0)
     {
         NGEditorPrefs.SetString(key, string.Join(TipsHelper.Separator.ToString(), this.disabledTips.ToArray()));
     }
     else if (NGEditorPrefs.HasKey(key) == true)
     {
         NGEditorPrefs.DeleteKey(key);
     }
 }
示例#21
0
        public override object  Fetch(object instance, Type type, string path)
        {
            Quaternion value = (Quaternion)instance;

            value.x = NGEditorPrefs.GetFloat(path + ".x", value.x);
            value.y = NGEditorPrefs.GetFloat(path + ".y", value.y);
            value.z = NGEditorPrefs.GetFloat(path + ".z", value.z);
            value.w = NGEditorPrefs.GetFloat(path + ".w", value.w);

            return(value);
        }
示例#22
0
        public override object  Fetch(object instance, Type type, string path)
        {
            Color value = (Color)instance;

            value.r = NGEditorPrefs.GetFloat(path + ".r", value.r);
            value.g = NGEditorPrefs.GetFloat(path + ".g", value.g);
            value.b = NGEditorPrefs.GetFloat(path + ".b", value.b);
            value.a = NGEditorPrefs.GetFloat(path + ".a", value.a);

            return(value);
        }
示例#23
0
 public void     Focus(string title)
 {
     for (int i = 0; i < NGSettingsWindow.sections.Count; i++)
     {
         if (NGSettingsWindow.sections[i].title == title)
         {
             this.workingSection = NGSettingsWindow.sections[i];
             NGEditorPrefs.SetString(NGSettingsWindow.LastSectionPrefKey, this.workingSection.title);
         }
     }
 }
示例#24
0
        protected virtual void  OnDisable()
        {
            Utility.UnregisterWindow(this);
            HQ.SettingsChanged     -= this.Repaint;
            Undo.undoRedoPerformed -= this.Repaint;

            if (this.workingSection != null)
            {
                NGEditorPrefs.SetString(NGSettingsWindow.LastSectionPrefKey, this.workingSection.title);
            }
        }
示例#25
0
        public override void    DirectSave(object instance, Type type, string path)
        {
            Object obj       = instance as Object;
            string assetPath = string.Empty;

            if (obj != null)
            {
                assetPath = AssetDatabase.GetAssetPath(obj);
            }

            NGEditorPrefs.SetString(path, assetPath);
        }
示例#26
0
        private static void                     OpenWindow(string type, string value)
        {
            UnityAssemblyVerifier.missing.Add(new KeyValuePair <string, string>(type, value));
            UnityAssemblyVerifier.cachedMissing = null;

            EditorApplication.delayCall += () =>
            {
                if (NGEditorPrefs.GetBool(UnityAssemblyVerifier.SkipWarningPrefKey) == false)
                {
                    EditorWindow.GetWindow <UnityAssemblyVerifier>(true, Constants.PackageTitle).CenterOnMainWin();
                }
            };
        }
示例#27
0
        public static void      CheckLatestVersion(string toolName)
        {
            if (NGEditorPrefs.GetBool(NGChangeLogWindow.DontNotifyNewUpdateKeyPref) == true)
            {
                return;
            }

            try
            {
                // Prevent repeating initialization.
                foreach (KeyValuePair <string, int> item in NGChangeLogWindow.pendingTools)
                {
                    if (item.Key == toolName)
                    {
                        return;
                    }
                }

                List <ChangeLog> changeLog;

                if (NGChangeLogWindow.changeLogs.TryGetValue(toolName, out changeLog) == true)
                {
                    changeLog.Sort((a, b) => a.version.CompareTo(b.version));

                    string local = NGChangeLogWindow.GetToolPath(toolName);
                    if (File.Exists(local) == true)
                    {
                        string version = File.ReadAllText(local);

                        for (int i = 0; i < changeLog.Count; i++)
                        {
                            if (version.CompareTo(changeLog[i].version) < 0)
                            {
                                NGChangeLogWindow.pendingTools.Enqueue(new KeyValuePair <string, int>(toolName, i));
                                NGChangeLogWindow.Open();
                                break;
                            }
                        }
                    }
                    else
                    {
                        File.WriteAllText(local, changeLog[changeLog.Count - 1].version);
                    }
                }
            }
            catch (Exception ex)
            {
                InternalNGDebug.LogException(ex);
            }
        }
示例#28
0
        public void     EraseAll(bool silent = false)
        {
            this.disabledTips.Clear();

            if (NGEditorPrefs.HasKey(key) == true)
            {
                NGEditorPrefs.DeleteKey(key);
            }

            if (silent == false)
            {
                EditorUtility.DisplayDialog(Constants.PackageTitle, "Tips have been reset.", "OK");
            }
        }
示例#29
0
文件: HQ.cs 项目: Hengle/clapotis
        internal static void    SetSendStats(object sendStats)
        {
            if ((bool)sendStats == false)
            {
                if (EditorUtility.DisplayDialog(Constants.PackageTitle, "For those who might want to know why I send stats.\nI need some info about Unity Editor usage, especially because Unity does not provide them.\nIn order to keep supporting legacy versions, unused tools or platforms such as Unity 4, Mac or else.\n\nDo you confirm not sending stats?", "Yes", "No") == false)
                {
                    return;
                }

                HQ.SendStats(false);
            }

            NGEditorPrefs.SetBool(HQ.AllowSendStatsKeyPref, (bool)sendStats);
        }
示例#30
0
        public void     Load(string key)
        {
            this.key = key;

            string data = NGEditorPrefs.GetString(key);

            if (string.IsNullOrEmpty(data) == false)
            {
                this.disabledTips.AddRange(data.Split(TipsHelper.Separator));
            }
            else
            {
                this.EraseAll(true);
            }
        }