/// <summary> /// Draw a table completely manually. /// Each cell has to be created and given as parameter in cells. /// </summary> /// <returns>The updated table state.</returns> /// <param name="tableState">The Table state.</param> /// <param name="columns">The Columns of the table.</param> /// <param name="cells">The Cells as a list of rows.</param> /// <param name="collectionProperty">The SerializeProperty of the collection. This is useful for reorderable tables.</param> /// <param name="options">The table options.</param> public static GUITableState DrawTable( GUITableState tableState, List <TableColumn> columns, List <List <TableCell> > cells, SerializedProperty collectionProperty, params GUITableOption[] options) { GUITableEntry tableEntry = new GUITableEntry(options); if (tableState == null) { tableState = new GUITableState(); tableState.CheckState(columns, tableEntry, float.MaxValue); } float requiredHeight = GUITable.TableHeight(tableEntry, cells.Count) + 10; if (tableEntry.allowScrollView && tableState.totalWidth + 19 > Screen.width / EditorGUIUtility.pixelsPerPoint) { requiredHeight += EditorGUIUtility.singleLineHeight; } Rect position = GUILayoutUtility.GetRect( tableEntry.allowScrollView ? Screen.width / EditorGUIUtility.pixelsPerPoint - 40 : tableState.totalWidth, requiredHeight); if (Event.current.type == EventType.Layout) { return(tableState); } else { return(GUITable.DrawTable(position, tableState, columns, cells, collectionProperty, options)); } }
protected virtual GUITableState DrawTable(Rect rect, SerializedProperty collectionProperty, GUIContent label, TableAttribute tableAttribute) { if (tableAttribute.properties == null && tableAttribute.widths == null) { return(GUITable.DrawTable(rect, tableState, collectionProperty, GUITableOption.AllowScrollView(false))); } else if (tableAttribute.widths == null) { return(GUITable.DrawTable(rect, tableState, collectionProperty, tableAttribute.properties.ToList(), GUITableOption.AllowScrollView(false))); } else { return(GUITable.DrawTable(rect, tableState, collectionProperty, GetPropertyColumns(tableAttribute), GUITableOption.AllowScrollView(false))); } }
protected virtual GUITableState DrawTable(Rect rect, SerializedProperty collectionProperty, GUIContent label, TableAttribute tableAttribute) { try { if (tableAttribute.properties == null) { return(GUITable.DrawTable(rect, tableState, collectionProperty, tableOptions)); } else { return(GUITable.DrawTable(rect, tableState, collectionProperty, tableAttribute.properties.ToList(), tableOptions)); } } catch (TableAttributeParsingException e) { Debug.LogError(e.Message + "\nGiving up drawing table for " + collectionProperty.name); return(tableState); } }
protected override GUITableState DrawTable(Rect rect, SerializedProperty collectionProperty, GUIContent label, TableAttribute tableAttribute) { if (tableState != null) { rect.width = Mathf.Min(rect.width, tableState.totalWidth + 20f); } if (tableAttribute.properties == null && tableAttribute.widths == null) { return(GUITable.DrawTable(rect, tableState, collectionProperty, GUITableOption.AllowScrollView(false), GUITableOption.Reorderable())); } else if (tableAttribute.widths == null) { return(GUITable.DrawTable(rect, tableState, collectionProperty, tableAttribute.properties.ToList(), GUITableOption.AllowScrollView(false), GUITableOption.Reorderable())); } else { return(GUITable.DrawTable(rect, tableState, collectionProperty, GetPropertyColumns(tableAttribute), GUITableOption.AllowScrollView(false), GUITableOption.Reorderable())); } }