public override void OnInspectorGUI() { if (h == null) { h = (HumanMonitor)target; } serializedObject.Update(); EditorGUILayout.PropertyField(serializedObject.FindProperty("meditionPeriod")); EditorGUILayout.PropertyField(serializedObject.FindProperty("meditionCount")); EditorGUILayout.PropertyField(serializedObject.FindProperty("loadData")); if (h.loadData) { EditorGUILayout.HelpBox("If you load the data, a dataset will be load and you will not play", MessageType.Warning); } EditorGUILayout.PropertyField(serializedObject.FindProperty("saveData")); if (!h.saveData) { EditorGUILayout.HelpBox("If you do not save your data, it will be lost", MessageType.Warning); } if (h.saveData || h.loadData) { var dropArea = GUILayoutUtility.GetRect(Screen.width, 35, GUILayout.MaxWidth(Screen.width - 40)); if (string.IsNullOrEmpty(h.dataPath)) { GUI.Box(dropArea, "Drag a data file"); } else { GUI.Box(dropArea, Path.GetFileName(h.dataPath)); } DragAndDropFile(dropArea); EditorGUILayout.Space(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Clear", GUILayout.MaxWidth(Screen.width / 2 - 20))) { h.dataPath = ""; } if (GUILayout.Button("Create", GUILayout.MaxWidth(Screen.width / 2 - 20))) { CreateFile(); } GUILayout.EndHorizontal(); } serializedObject.ApplyModifiedProperties(); }
void OnEnable() { h = (HumanMonitor)target; }