예제 #1
0
 public static void      DeleteKey(string key, bool perProject = false)
 {
     if (perProject == true)
     {
         key = NGEditorPrefs.GetPerProjectPrefix() + key;
     }
     EditorPrefs.DeleteKey(key);
 }
예제 #2
0
 public static bool      HasKey(string key, bool perProject = false)
 {
     if (perProject == true)
     {
         key = NGEditorPrefs.GetPerProjectPrefix() + key;
     }
     return(EditorPrefs.HasKey(key));
 }
예제 #3
0
 public static string    GetString(string key, string defaultValue = "", bool perProject = false)
 {
     if (perProject == true)
     {
         key = NGEditorPrefs.GetPerProjectPrefix() + key;
     }
     return(EditorPrefs.GetString(key, defaultValue));
 }
예제 #4
0
 public static void              SetString(string key, string value, bool perProject = false)
 {
     if (perProject == true)
     {
         key = NGEditorPrefs.GetPerProjectPrefix() + key;
     }
     EditorPrefs.SetString(key, value);
 }
예제 #5
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));
 }
예제 #6
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));
 }
예제 #7
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));
 }
예제 #8
0
        public override void    Save(object instance, FieldInfo field, string prefix)
        {
            IList list = field.GetValue(instance) as IList;

            prefix += instance.GetType().FullName + '.' + field.Name;
            NGEditorPrefs.SetInt(prefix, list.Count);
            prefix += '.';

            for (int i = 0; i < list.Count; i++)
            {
                NGEditorPrefs.SetString(prefix + i, Convert.ToBase64String(Utility.SerializeField(list[i])));
            }
        }
예제 #9
0
        public override void    Load(object instance, FieldInfo field, string prefix)
        {
            IList list    = field.GetValue(instance) as IList;
            int   count   = NGEditorPrefs.GetInt(prefix + instance.GetType().FullName + '.' + field.Name, -1);
            Type  subType = Utility.GetArraySubType(field.FieldType);

            if (count != -1)
            {
                list.Clear();

                prefix += instance.GetType().FullName + '.' + field.Name + '.';

                try
                {
                    for (int i = 0; i < count; i++)
                    {
                        object element = null;
                        string v       = NGEditorPrefs.GetString(prefix + i, null);

                        if (v != null)
                        {
                            element = Utility.DeserializeField <object>(Convert.FromBase64String(v));
                        }
                        else if (subType.IsValueType == true)
                        {
                            element = Activator.CreateInstance(subType);
                        }

                        list.Add(element);
                    }

                    field.SetValue(instance, list);
                }
                catch (Exception ex)
                {
                    InternalNGDebug.LogException(prefix, ex);
                }
            }
        }
예제 #10
0
 public override void    Load(object instance, FieldInfo field, string prefix)
 {
     field.SetValue(instance, NGEditorPrefs.GetString(prefix + instance.GetType().FullName + '.' + field.Name, (String)(this.GetDefaultValue(field) ?? field.GetValue(instance))));
 }
예제 #11
0
 public override void    Save(object instance, FieldInfo field, string prefix)
 {
     NGEditorPrefs.SetString(prefix + instance.GetType().FullName + '.' + field.Name, (String)field.GetValue(instance));
 }