private void CellGUI(Rect cellRect, SerializedPropertyItem item, int columnIndex, ref RowGUIArgs args) { Profiler.BeginSample("SerializedPropertyTreeView.CellGUI"); CenterRectUsingSingleLineHeight(ref cellRect); var data = item.GetData(); var column = (Column)multiColumnHeader.GetColumn(columnIndex); if (column.drawDelegate == DefaultDelegates.s_DrawName) { Profiler.BeginSample("SerializedPropertyTreeView.OnItemGUI.LabelField"); DefaultGUI.Label(cellRect, data.Name, IsSelected(args.item.id), false); Profiler.EndSample(); } else if (column.drawDelegate != null) { var properties = data.Properties; var num = column.dependencyIndices == null ? 0 : column.dependencyIndices.Length; for (var i = 0; i < num; i++) { m_ColumnsInternal[columnIndex].dependencyProps[i] = properties[column.dependencyIndices[i]]; } if (args.item.id == state.lastClickedID && HasFocus() && columnIndex == multiColumnHeader.state.visibleColumns[multiColumnHeader.state.visibleColumns[0] != 0 ? 0 : 1]) { GUI.SetNextControlName(Styles.focusHelper); } var serializedProperty = data.Properties[columnIndex]; EditorGUI.BeginChangeCheck(); Profiler.BeginSample("SerializedPropertyTreeView.OnItemGUI.drawDelegate"); column.drawDelegate(cellRect, serializedProperty, m_ColumnsInternal[columnIndex].dependencyProps); Profiler.EndSample(); if (EditorGUI.EndChangeCheck()) { m_ChangedId = column.filter == null || !column.filter.Active() ? m_ChangedId : GUIUtility.keyboardControl; data.Store(); var selection = GetSelection(); if (selection.Contains(data.ObjectId)) { var list = FindRows(selection); Undo.RecordObjects((from r in list select((SerializedPropertyItem)r).GetData() .SerializedObject.targetObject).ToArray(), "Modify Multiple Properties"); foreach (var current in list) { if (current.id != args.item.id) { var data2 = ((SerializedPropertyItem)current).GetData(); if (IsEditable(data2.SerializedObject.targetObject)) { if (column.copyDelegate != null) { column.copyDelegate(data2.Properties[columnIndex], serializedProperty); } else { DefaultDelegates.s_CopyDefault(data2.Properties[columnIndex], serializedProperty); } data2.Store(); } } } } } Profiler.EndSample(); } }
void CellGUI(Rect cellRect, SerializedPropertyItem item, int columnIndex, ref RowGUIArgs args) { Profiler.BeginSample("SerializedPropertyTreeView.CellGUI"); CenterRectUsingSingleLineHeight(ref cellRect); var ltd = item.GetData(); Column column = (Column)this.multiColumnHeader.GetColumn(columnIndex); if (column.drawDelegate == DefaultDelegates.s_DrawName) { // default drawing Profiler.BeginSample("SerializedPropertyTreeView.OnItemGUI.LabelField"); DefaultGUI.Label(cellRect, ltd.name, IsSelected(args.item.id), false); Profiler.EndSample(); } else if (column.drawDelegate != null) { SerializedProperty[] props = ltd.properties; int depcnt = column.dependencyIndices != null ? column.dependencyIndices.Length : 0; for (int i = 0; i < depcnt; i++) { m_ColumnsInternal[columnIndex].dependencyProps[i] = props[column.dependencyIndices[i]]; } // allow to capture tabs if (args.item.id == state.lastClickedID && HasFocus() && columnIndex == multiColumnHeader.state.visibleColumns[multiColumnHeader.state.visibleColumns[0] == 0 ? 1 : 0]) { GUI.SetNextControlName(Styles.focusHelper); } SerializedProperty prop = ltd.properties[columnIndex]; EditorGUI.BeginChangeCheck(); Profiler.BeginSample("SerializedPropertyTreeView.OnItemGUI.drawDelegate"); column.drawDelegate(cellRect, prop, m_ColumnsInternal[columnIndex].dependencyProps); Profiler.EndSample(); if (EditorGUI.EndChangeCheck()) { // if we changed a value in a filtered column we'll have to reload the table m_ChangedId = ((column.filter != null) && column.filter.Active()) ? GUIUtility.keyboardControl : m_ChangedId; // update all selected items if the current row was part of the selection list ltd.Store(); var selIds = GetSelection(); if (selIds.Contains(ltd.objectId)) { IList <TreeViewItem> rows = FindRows(selIds); Undo.RecordObjects(rows.Select(r => ((SerializedPropertyItem)r).GetData().serializedObject.targetObject).ToArray(), "Modify Multiple Properties"); foreach (var r in rows) { if (r.id == args.item.id) { continue; } var data = ((SerializedPropertyItem)r).GetData(); if (!IsEditable(data.serializedObject.targetObject)) { continue; } if (column.copyDelegate != null) { column.copyDelegate(data.properties[columnIndex], prop); } else { DefaultDelegates.s_CopyDefault(data.properties[columnIndex], prop); } data.Store(); } } } Profiler.EndSample(); } }