- Home /
EditorWindow Table - is it possible?
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?
Is this just an arbitrary example, or do you want to make an sql table editor / creator? There are plenty of programs out there that can handle this way better ;)
The UnityGUI isn't that complicated, if you have an example data set, i can post an example.
It's to make a new table, so not for mysql or anything like that. I've learnt a bit of UnityGui so I'm going to sit down and try tackle this. Thank you for your input in any case
You can take a look at my UPP editor ;)
It also uses a table / grid like editor.
Answer by Paulius-Liekis · Jul 18, 2012 at 09:59 AM
No, there is no support out of the box, but you can do it yourself.
See some answers here: http://answers.unity3d.com/questions/12108/something-like-guitable-or-a-grid.html
Answer by cr4y · Apr 04, 2020 at 12:09 PM
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);
}
Answer by bourriquet · Nov 24, 2018 at 04:30 PM
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 [Table] before the collection declaration to display it in a table.
Here's how it looks:
I hope it helps!
Your answer
Follow this Question
Related Questions
how to make a visual editorwindow 0 Answers
Editor Windows - Where to get started? 1 Answer
OnDrawGizmos from EditorWindow 1 Answer
Open scene and load prefab 1 Answer
OnEditorQuit? 1 Answer