public static void Load(PaintParam param, string path) { string filePath = Path.Combine(path, SERIALIZED_NAME); if (File.Exists(filePath)) { EditorJsonUtility.FromJsonOverwrite(File.ReadAllText(filePath), param); } }
void OnDisable() { PaintParam.Save(param, SERIALIZED_PATH); SceneView.onSceneGUIDelegate -= SceneGUI; if (paintPosition) { DestroyImmediate(paintPosition.gameObject); } }
public static void Save(PaintParam param, string path) { string filePath = Path.Combine(path, SERIALIZED_NAME); if (File.Exists(filePath)) { File.Delete(filePath); } File.WriteAllText(filePath, EditorJsonUtility.ToJson(param)); }
/// <summary> /// Called on start /// </summary> void OnEnable() { SERIALIZED_PATH = Application.persistentDataPath; param = new PaintParam(); PaintParam.Load(param, SERIALIZED_PATH); SceneView.onSceneGUIDelegate += SceneGUI; if (param.objects == null) { param.objects = new List <PaintObject>(); } layerNames = new List <string>(); int count = 0; for (int i = 0; i <= 31; i++) { layerNames.Add(LayerMask.LayerToName(i)); count++; } }