Ejemplo n.º 1
0
        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()));
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
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);
         }
     }
 }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
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);
     }
 }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        public override void    DirectSave(object instance, Type type, string path)
        {
            Array array = instance as Array;

            if (array == null)
            {
                NGEditorPrefs.DeleteKey(path);
                return;
            }

            NGEditorPrefs.SetInt(path, array.Length);

            try
            {
                if (array.Length > 0)
                {
                    Type subType = Utility.GetArraySubType(type);

                    if (subType.IsValueType == true || subType == typeof(string) || subType.IsInterface == true || subType.IsAbstract == true)
                    {
                        NGEditorPrefs.SetString(path + ".serialized", Convert.ToBase64String(Utility.SerializeField(array)));
                        return;
                    }
                }

                for (int i = 0; i < array.Length; i++)
                {
                    object value = array.GetValue(i);

                    if (value != null)
                    {
                        Utility.DirectSaveEditorPref(value, value.GetType(), path + '.' + i);
                    }
                    else
                    {
                        NGEditorPrefs.DeleteKey(path + '.' + i);
                    }
                }
            }
            catch (Exception ex)
            {
                InternalNGDebug.LogException("EditorPrefArray failed saving at \"" + path + "\".", ex);
            }
        }
Ejemplo n.º 8
0
        public override void    DirectSave(object instance, Type type, string path)
        {
            IList list = instance as IList;

            if (list == null)
            {
                NGEditorPrefs.DeleteKey(path);
                return;
            }

            NGEditorPrefs.SetInt(path, list.Count);

            try
            {
                if (list.Count > 0)
                {
                    Type subType = Utility.GetArraySubType(type);

                    if ((subType.IsValueType == true && subType.IsStruct() == false) || subType == typeof(string) || subType.IsInterface == true || subType.IsAbstract == true)
                    {
                        NGEditorPrefs.SetString(path + ".serialized", Convert.ToBase64String(Utility.SerializeField(list)));
                        return;
                    }
                }

                for (int i = 0; i < list.Count; i++)
                {
                    object value = list[i];

                    if (value != null)
                    {
                        Utility.DirectSaveEditorPref(value, value.GetType(), path + '.' + i);
                    }
                    else
                    {
                        NGEditorPrefs.DeleteKey(path + '.' + i);
                    }
                }
            }
            catch (Exception ex)
            {
                InternalNGDebug.LogException("EditorPrefList failed saving at \"" + path + "\".", ex);
            }
        }
Ejemplo n.º 9
0
 public override void    DirectSave(object instance, Type type, string path)
 {
     NGEditorPrefs.SetString(path, ((Decimal)instance).ToString());
 }
Ejemplo n.º 10
0
 public static void              SaveLanguage(string language)
 {
     NGEditorPrefs.SetString(Constants.LanguageEditorPref, language);
 }
Ejemplo n.º 11
0
 public override void    DirectSave(object instance, Type type, string path)
 {
     NGEditorPrefs.SetString(path, (String)instance);
 }