Esempio n. 1
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);
                }
            }
        }
Esempio n. 2
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))));
 }