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); } }
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); } }
public override void DirectSave(object instance, Type type, string path) { NGEditorPrefs.SetInt(path, (Int32)instance); }