Exemplo n.º 1
0
        /// <summary>
        /// Draw a table just from the collection's property.
        /// This will create columns for all the visible members in the elements' class,
        /// similar to what Unity would show in the classic vertical collection display, but as a table instead.
        /// </summary>
        /// <returns>The updated table state.</returns>
        /// <param name="rect">The table's containing rectangle.</param>
        /// <param name="tableState">The Table state.</param>
        /// <param name="collectionProperty">The serialized property of the collection.</param>
        /// <param name="options">The table options.</param>
        public static GUITableState DrawTable(
            Rect rect,
            GUITableState tableState,
            SerializedProperty collectionProperty,
            params GUITableOption[] options)
        {
            bool          isObjectReferencesCollection = false;
            List <string> properties = SerializationHelpers.GetElementsSerializedFields(collectionProperty, out isObjectReferencesCollection);

            if (properties == null && collectionProperty.arraySize == 0)
            {
                DrawTable(
                    rect,
                    null,
                    new List <TableColumn> ()
                {
                    new TableColumn(collectionProperty.displayName + "(properties unknown, add at least 1 element)", TableColumn.Sortable(false), TableColumn.Resizeable(false))
                },
                    new List <List <TableCell> > (),
                    collectionProperty,
                    options);
                return(tableState);
            }
            if (isObjectReferencesCollection)
            {
                List <SelectorColumn> columns = new List <SelectorColumn> ();
                columns.Add(new SelectObjectReferenceColumn("Object Reference", TableColumn.Optional(true)));
                columns.AddRange(properties.Select(prop => (SelectorColumn) new SelectFromPropertyNameColumn(prop, ObjectNames.NicifyVariableName(prop))));
                return(DrawTable(rect, tableState, collectionProperty, columns, options));
            }
            return(DrawTable(rect, tableState, collectionProperty, properties, options));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Draw a table just from the collection's property.
        /// This will create columns for all the visible members in the elements' class,
        /// similar to what Unity would show in the classic vertical collection display, but as a table instead.
        /// </summary>
        /// <returns>The updated table state.</returns>
        /// <param name="tableState">The Table state.</param>
        /// <param name="collectionProperty">The serialized property of the collection.</param>
        /// <param name="options">The table options.</param>
        public static GUITableState DrawTable(
            GUITableState tableState,
            SerializedProperty collectionProperty,
            params GUITableOption[] options)
        {
            List <string> properties = SerializationHelpers.GetElementsSerializedFields(collectionProperty);

            if (properties == null && collectionProperty.arraySize == 0)
            {
                DrawTable(
                    null,
                    new List <TableColumn> ()
                {
                    new TableColumn(TableColumn.Title(collectionProperty.displayName + "(properties unknown, add at least 1 element)"), TableColumn.Sortable(false), TableColumn.Resizeable(false))
                },
                    new List <List <TableCell> > (),
                    collectionProperty,
                    options);
                return(tableState);
            }
            return(DrawTable(tableState, collectionProperty, properties, options));
        }