Hi folks, is it possible to add a table to EditorWindow, which can be edited? for example, like in the column below, could I create a table with my own column headings, and the ability to add a new entry by clicking on the last entry?
No, there is no support out of the box, but you can do it yourself.
See some answers here: Something like GUI.Table or a Grid? - Questions & Answers - Unity Discussions
I had the same problem so I’ve developed a solution.
Please put the code below in Grid.cs file
using UnityEngine;
class Grid {
readonly int height, width;
Rect currentRow;
int lastX = 0;
public Grid(int width, int height) {
this.width = width;
this.height = height;
}
public Rect GetRect() {
if (!EnoughSpaceInCurrentRow()) {
currentRow = GUILayoutUtility.GetRect(width, height);
lastX = 0;
}
return GetNextRectInCurrentRow();
}
bool EnoughSpaceInCurrentRow() {
return currentRow.width >= lastX + width;
}
Rect GetNextRectInCurrentRow() {
var ret = new Rect(currentRow) {x = lastX, width = width};
lastX += width;
return ret;
}
}
Then you can use it like this:
var grid = new Grid(100, 50);
for (int i = 1; i < 100; ++i) {
var rect = grid.GetRect();
GUI.Button(rect, "Button " +i);
}
I looked for a way to do exactly that too, so I developed
Editor GUI Table
The table has all the nice features you could expect like sorting rows, resizing, optional columns…
Just add ** before the collection declaration to display it in a table.
Here’s how it looks:
I hope it helps!