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; } } }
void OnModelSelected(BaseModel target) { model = target; if (model == null || model.NameSpace.Equals("MB2Editor") || model.element.Equals("Unassigned")) { notSupport = EditorNotSupport.Unassigned; } else { DataSetConfig config; if (ConfigManager.GetConfig(model.NameSpace, out config)) { //TODO: need cache view here for perfermance var supportDataSet = config.Datasets.Where((element) => element.NestedElements.Any((nestedElement) => nestedElement.Name.Equals(model.element))); datasetViews = supportDataSet.Select((dataset) => { MB2CustomEditorView view; if (!ElementViewManager.GetView(dataset.Name, out view)) { view = new DataSetView(); } view.Init(dataset); return(view); }).ToArray(); if (datasetViews.Length > 0) { notSupport = EditorNotSupport.Support; } else { notSupport = EditorNotSupport.NoView; } } else { notSupport = EditorNotSupport.NoView; } } Repaint(); }
public DataSetPanel() { notSupport = EditorNotSupport.Unassigned; titleContent = new GUIContent("DataSet Viewer"); }