void InitIfNeeded() { if (m_Initialized) { return; } if (m_TreeViewState == null) { m_TreeViewState = new TreeViewState(); } if (m_MultiColumnHeaderState == null) { SerializedPropertyTreeView.Column[] columns = m_HeaderDelegate(); string[] propNames = GetPropertyNames(columns); m_MultiColumnHeaderState = new MultiColumnHeaderState(columns); m_DataStore = new SerializedPropertyDataStore(propNames, m_GatherDelegate); } var header = new MultiColumnHeader(m_MultiColumnHeaderState); m_ColumnHeaderHeight = header.height; m_TreeView = new SerializedPropertyTreeView(m_TreeViewState, header, m_DataStore); m_TreeView.DeserializeState(m_SerializationUID); m_TreeView.Reload(); m_Initialized = true; }
private void InitIfNeeded() { if (!this.m_Initialized) { if (this.m_TreeViewState == null) { this.m_TreeViewState = new TreeViewState(); } if (this.m_MultiColumnHeaderState == null) { string[] propNames; this.m_MultiColumnHeaderState = new MultiColumnHeaderState(this.m_HeaderDelegate(out propNames)); this.m_DataStore = new SerializedPropertyDataStore(propNames, this.m_GatherDelegate); } MultiColumnHeader multiColumnHeader = new MultiColumnHeader(this.m_MultiColumnHeaderState); this.m_ColumnHeaderHeight = multiColumnHeader.height; this.m_TreeView = new SerializedPropertyTreeView(this.m_TreeViewState, multiColumnHeader, this.m_DataStore); this.m_TreeView.DeserializeState(this.m_SerializationUID); this.m_TreeView.Reload(); this.m_Initialized = true; } }
private void CellGUI(Rect cellRect, SerializedPropertyTreeView.SerializedPropertyItem item, int columnIndex, ref TreeView.RowGUIArgs args) { Profiler.BeginSample("SerializedPropertyTreeView.CellGUI"); base.CenterRectUsingSingleLineHeight(ref cellRect); SerializedPropertyDataStore.Data data = item.GetData(); SerializedPropertyTreeView.Column column = (SerializedPropertyTreeView.Column)base.multiColumnHeader.GetColumn(columnIndex); if (column.drawDelegate == SerializedPropertyTreeView.DefaultDelegates.s_DrawName) { Profiler.BeginSample("SerializedPropertyTreeView.OnItemGUI.LabelField"); TreeView.DefaultGUI.Label(cellRect, data.name, base.IsSelected(args.item.id), false); Profiler.EndSample(); } else if (column.drawDelegate != null) { SerializedProperty[] properties = data.properties; int num = (column.dependencyIndices == null) ? 0 : column.dependencyIndices.Length; for (int i = 0; i < num; i++) { this.m_ColumnsInternal[columnIndex].dependencyProps[i] = properties[column.dependencyIndices[i]]; } if (args.item.id == base.state.lastClickedID && base.HasFocus() && columnIndex == base.multiColumnHeader.state.visibleColumns[(base.multiColumnHeader.state.visibleColumns[0] != 0) ? 0 : 1]) { GUI.SetNextControlName(SerializedPropertyTreeView.Styles.focusHelper); } SerializedProperty serializedProperty = data.properties[columnIndex]; EditorGUI.BeginChangeCheck(); Profiler.BeginSample("SerializedPropertyTreeView.OnItemGUI.drawDelegate"); column.drawDelegate(cellRect, serializedProperty, this.m_ColumnsInternal[columnIndex].dependencyProps); Profiler.EndSample(); if (EditorGUI.EndChangeCheck()) { this.m_ChangedId = ((column.filter == null || !column.filter.Active()) ? this.m_ChangedId : GUIUtility.keyboardControl); data.Store(); IList <int> selection = base.GetSelection(); if (selection.Contains(data.objectId)) { IList <TreeViewItem> list = base.FindRows(selection); Undo.RecordObjects((from r in list select((SerializedPropertyTreeView.SerializedPropertyItem)r).GetData().serializedObject.targetObject).ToArray <UnityEngine.Object>(), "Modify Multiple Properties"); foreach (TreeViewItem current in list) { if (current.id != args.item.id) { SerializedPropertyDataStore.Data data2 = ((SerializedPropertyTreeView.SerializedPropertyItem)current).GetData(); if (SerializedPropertyTreeView.IsEditable(data2.serializedObject.targetObject)) { if (column.copyDelegate != null) { column.copyDelegate(data2.properties[columnIndex], serializedProperty); } else { SerializedPropertyTreeView.DefaultDelegates.s_CopyDefault(data2.properties[columnIndex], serializedProperty); } data2.Store(); } } } } } Profiler.EndSample(); } }