//... void OnGUI() { if (targetType == null) { return; } var e = Event.current; if (e.type == EventType.ValidateCommand && e.commandName == "UndoRedoPerformed") { GUIUtility.hotControl = 0; GUIUtility.keyboardControl = 0; e.Use(); return; } GUILayout.Space(10); GUILayout.Label(string.Format("<size=14><b>{0}</b></size>", targetType.FriendlyName()), Styles.centerLabel); EditorUtils.Separator(); GUILayout.Space(10); scrollPos = GUILayout.BeginScrollView(scrollPos); var serializationInfo = new InspectedFieldInfo(unityObjectContext, null, null, null); var oldValue = read(); var newValue = EditorUtils.ReflectedFieldInspector(friendlyTitle, oldValue, targetType, serializationInfo); if (!Equals(oldValue, newValue) || GUI.changed) { write(newValue); } GUILayout.EndScrollView(); willRepaint = true; }
//... void OnGUI() { if (targetType == null) { return; } //Begin undo check GUI.skin.label.richText = true; UndoManager.CheckUndo(context, "Blackboard External Inspector"); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(string.Format("<size=14><b>{0}</b></size>", targetType.FriendlyName())); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(10); scrollPos = GUILayout.BeginScrollView(scrollPos); value = EditorUtils.ReflectedFieldInspector(targetType.FriendlyName(), value, targetType, null, null); GUILayout.EndScrollView(); Repaint(); //Check dirty UndoManager.CheckDirty(context); }