void DrawCustomCells()
    {
        SerializedObject serializedObject = new SerializedObject(SimpleExample.Instance);

        List <TableColumn> columns = new List <TableColumn>()
        {
            new TableColumn("String", TableColumn.Width(60f)),
            new TableColumn("Float", TableColumn.Width(50f)),
            new TableColumn("Object", TableColumn.Width(110f)),
            new TableColumn("", TableColumn.Width(100f), TableColumn.EnabledTitle(false)),
        };

        List <List <TableCell> > rows = new List <List <TableCell> >();

        SimpleExample targetObject = (SimpleExample)serializedObject.targetObject;

        for (int i = 0; i < targetObject.simpleObjects.Count; i++)
        {
            SimpleExample.SimpleObject entry = targetObject.simpleObjects[i];
            rows.Add(new List <TableCell>()
            {
                new LabelCell(entry.stringProperty),
                new PropertyCell(serializedObject, string.Format("simpleObjects.Array.data[{0}].floatProperty", i)),
                new PropertyCell(serializedObject, string.Format("simpleObjects.Array.data[{0}].objectProperty", i)),
                new ActionCell("Reset", () => entry.Reset()),
            });
        }

        tableState = GUITableLayout.DrawTable(tableState, columns, rows);
    }
示例#2
0
    void DrawCustomEntries()
    {
        SerializedObject serializedObject = new SerializedObject(SimpleExample.Instance);

        List <TableColumn> columns = new List <TableColumn>()
        {
            new TableColumn("String", 60f),
            new TableColumn("Float", 50f),
            new TableColumn("Object", 110f),
            new TableColumn("", 100f)
            {
                enabledTitle = false
            },
        };

        List <List <TableEntry> > rows = new List <List <TableEntry> >();

        SimpleExample targetObject = (SimpleExample)serializedObject.targetObject;

        for (int i = 0; i < targetObject.simpleObjects.Count; i++)
        {
            SimpleExample.SimpleObject entry = targetObject.simpleObjects[i];
            rows.Add(new List <TableEntry>()
            {
                new LabelEntry(entry.stringProperty),
                new PropertyEntry(serializedObject, string.Format("simpleObjects.Array.data[{0}].floatProperty", i)),
                new PropertyEntry(serializedObject, string.Format("simpleObjects.Array.data[{0}].objectProperty", i)),
                new ActionEntry("Reset", () => entry.Reset()),
            });
        }

        tableState = GUITable.DrawTable(columns, rows, tableState);
    }