/// <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));
            }
        }
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            if (!IsFirstElementQuickCheck(property.propertyPath))
            {
                if (!IsCollectionQuickCheck(property.propertyPath))
                {
                    return(EditorGUIUtility.singleLineHeight);
                }
                return(0);
            }

            string collectionPath, index;

            if (!IsCollectionFullCheck(property.propertyPath, out index, out collectionPath))
            {
                return(EditorGUIUtility.singleLineHeight);
            }

            if (index != "0")
            {
                return(0);
            }

            GUITableEntry      tableEntry         = new GUITableEntry(tableOptions);
            SerializedProperty collectionProperty = property.serializedObject.FindProperty(collectionPath);

            return(collectionProperty.arraySize * (GUITable.RowHeight(tableEntry) - 2) + EditorGUIUtility.singleLineHeight + GUITable.HeadersHeight(tableEntry) + GUITable.ExtraHeight(tableEntry));
        }
Exemple #3
0
 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);
     }
 }
Exemple #5
0
 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()));
     }
 }