public static bool GetView(string elementName, out MB2CustomEditorView view, string nameSpace = null) { if (elementName != null) { Type viewType; if (nameSpace != null) { Dictionary <string, Type> dict; if (registeredView.TryGetValue(nameSpace, out dict)) { if (dict.TryGetValue(elementName, out viewType)) { view = CreateView(viewType); return(true); } } } if (registeredViewGlobal.TryGetValue(elementName, out viewType)) { view = CreateView(viewType); return(true); } } view = null; return(false); }
/// <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); }
void OnEnable() { notSupport = EditorNotSupport.Support; model = this.target as BaseModel; // need to be assigned if (model.NameSpace.Equals("MB2Editor") && model.element.Equals("Unassigned")) { notSupport = EditorNotSupport.Unassigned; } else { //TODO: need cache view here for perfermance DataSetConfig config; ElementConfig elementConfig; if (ConfigManager.GetConfig(model.NameSpace, out config) && ((elementConfig = config.elements.First((ele) => ele.Name.Equals(model.element))) != null)) { // check version if (model.version != config.version) { if (config.DataUpdate != null) { string updatedData; if (config.DataUpdate.Update(model.element, model.serilizedData, model.version, out updatedData)) { model.version = config.version; model.serilizedData = updatedData; } else { notSupport = EditorNotSupport.NoUpdate; } } else { notSupport = EditorNotSupport.NoUpdate; } } if (notSupport == EditorNotSupport.Support) { view = new ElementView(); view.Init(elementConfig); view.OnEnable(model.serilizedData); } } else { notSupport = EditorNotSupport.NoView; } } }
/// <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(); }