public override void OnInspectorGUI() { serializedObject.Update(); using (var changeScope = new EditorGUI.ChangeCheckScope()) { using (new GUILayout.VerticalScope(EditorStyles.helpBox)) { EditorGUILayout.PropertyField(resetBool); } using (new GUILayout.VerticalScope(EditorStyles.helpBox)) { if (EditorApplication.isPlaying || !resetBool.boolValue) { EditorGUILayout.PropertyField(initialValue); EditorGUILayout.PropertyField(runtimeValue); } else { EditorGUILayout.PropertyField(initialValue); if (changeScope.changed) { serializedObject.ApplyModifiedProperties(); global.Reset(); serializedObject.Update(); return; } EditorGUILayout.TextField(runtimeValue.displayName, global.RuntimeValueToString(), EditorStyles.label); } } if (GUILayout.Button("Reset")) { ResetAndUpdate(); } if (changeScope.changed) { serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(this); } } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); if (GUILayout.Button("Reset")) { using (var changeScope = new EditorGUI.ChangeCheckScope()) { global.Reset(); serializedObject.Update(); EditorUtility.SetDirty(this); } } }