public override void OnInspectorGUI() { if (notSupport != EditorNotSupport.Support) { switch (notSupport) { case EditorNotSupport.NoUpdate: EditorGUILayout.HelpBox("The version of data doesn't match current editor", MessageType.Warning); break; case EditorNotSupport.Unassigned: EditorGUILayout.HelpBox("You need to assign the type of data before editing", MessageType.Warning); OnAssignTypeGUI(); break; case EditorNotSupport.NoView: default: EditorGUILayout.HelpBox("This Element not support to edit", MessageType.Warning); break; } } else { EditorGUI.BeginChangeCheck(); view.OnGUI(); if (EditorGUI.EndChangeCheck()) { //TODO: Implement REDO/UNDO //Undo.RecordObject(target, "update serialized data"); model.serilizedData = view.GetData(); EditorUtility.SetDirty(this.target); } } }
/// <summary> /// Called when the nested element view will be render, Call OnGUI on it to render /// </summary> /// <param name="currentView">the nested element view</param> /// <param name="isOpen">whether the view is expanded by user</param> /// <param name="elementName">the name of the element</param> /// <returns>whether the view is expanded by user</returns> protected virtual bool NestedElementOnGUI(MB2CustomEditorView currentView, bool isOpen, string elementName) { isOpen = EditorGUILayout.BeginFoldoutHeaderGroup(isOpen, elementName); EditorGUILayout.EndFoldoutHeaderGroup(); if (isOpen) { EditorGUI.indentLevel++; currentView.OnGUI(); EditorGUI.indentLevel--; } return(isOpen); }
/// <summary> /// Called when the attribute view will be render, Call OnGUI on it to render /// </summary> /// <param name="currentView">the attribute view</param> protected virtual void AttributeOnGUI(MB2CustomEditorView currentView) { currentView.OnGUI(); }