コード例 #1
0
ファイル: GUITableLayout.cs プロジェクト: Syy9/EditorGUITable
        /// <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));
            }
        }