A beautiful, easy-to-use and customizable table to display in the Unity Editor!
This package helps programmers create nice visual editors for artists and game designers to use in the Editor.
Forget the neverending lists of lists of parameters to tweak!
It uses the GUI elements and just organizes them in a table, so the style is consistent with the rest of the editor.
Many levels of simplicity / customization
Just use the [/I] attribute on a collection. Or draw it yourself in Editor scripts, using one of many ways, from the basic to the most complex. - Just give the collection as parameter and let the plugin automatically create columns for each property - Choose which properties you want to display - Choose which properties you want to display + customize the columns - Pass functions that create the cells from the elements of the collection - Create each cell to draw in the table All the nice options - Sort by a column - Resize columns - Optional columns - Reorder the elements - Filter the content
Hi Jeremy, is it possible to set the width of the table by default on the custom inspector size for the attribute ? And to refresh that when it is resized ?
I have this kind of problem and this is not really handy :
Hi @Dizy
Very sorry for the late answer!
You can set the size of each column when using the attribute like so:
[Table(new string [] {"property1", "property2"}, new float[] {200f, 250f})]
(Note that C# Attributes can only accept primitive types as parameters, this is why this signature seems a bit like poor design. C# specs for reference)
About relative sizes, it is not implemented right now, but I will look into it. Thank you for the suggestion.
Hi @Dizy
I integrated the Relative columns feature in Version 2.2, which is released now.
Add the option “Relative (true)” to a column, the Width value will now be relative instead of absolute (0.5 means 50% of the containing view, etc).
Relative columns will automatically resize with the view.
You can add options with the attribute by adding them after the property name.
For example:
Thx for the reply, i tested the 2.2 version and it works like a charm but the scroll bar is not taken into account and i have to use an offset of 0.1 to fit (not the best result).
Example :
[ReorderableTable(new[ ]{“Biome: Relative(true)”, “Rank: Relative(true)”}, new[ ]{0.45f, 0.45f})]
public List FavoriteBiomes = new List();
But I found one issue that took me some time to realize what was going wrong…
When a property I want to show in a table has the [Header(“blabla”)] attribute attached, the cell drawer seems to have a problem with it, and draws a misplaced dropdown menu with the header name set, that cannot be manipulated.
I see where the issue comes from. But what I don’t know is: what would you expect/like the table to do here? Would you want the header to be in his own column? Or to be ignored in the table?
The issue goes down to the way unity decorator attributes like [Header] work. Even if they sound like independent elements, decorators are technically linked to the next field declared (try to place a header with no serialized property below, you will see it fails because there is no field to attach it to).
So here the header is actually an attribute of your shipName field. This attribute will increase the height of the field, draw the header on top and the actual property at the bottom. Here the table has the default row height value, so the header+property doesn’t fit in a row.
If you use the Table’s RowHeight option to set it to a bigger value (say 100), you will see the header being drawn at the top of each cell in the shipName column. But I guess that’s not what you want to do
thanks for the fast response! Hey man, it’s christmas… go home and celebrate!
But regarding your question: it would be nice if the [Header] would be just ignored… I use it to make the inspector more readable, or to arrange properties better under one “category”… as you guessed - the header has nothing to do with that particuliar item, but the items to come afterwards…
Not sure if my idea fits into your plugin?
Thanks again man, and now: go home and stay there for at least the next 3 days
Sebastian
Don’t worry about me, I’m enjoying the holidays with the family
That makes sense, I’ll see if that’s possible to ignore an attribute while drawing a property.
In the meantime, if you are using an editor script to draw the table, you can use custom columns to avoid drawing the header (code below).
If you are using the attribute, I don’t think there is a solution here. You could add a bullshit property between the header and the shipName, so the header is attached to this BS property that you just don’t select for the table. That’s the best I can think of.
Here is the DrawTable call you could use in an editor script.
tableState = GUITableLayout.DrawTable (
tableState,
serializedObject.FindProperty("shipDefinitions"),
new List<SelectorColumn>()
{
new SelectFromFunctionColumn(
sp => new StringCell(sp.FindPropertyRelative("shipName")),
TableColumn.Title("Ship Name")),
new SelectFromPropertyNameColumn("xp")
});
And you’ll need to add this StringCell class in an Editor Folder:
using UnityEngine;
using UnityEditor;
using EditorGUITable;
class StringCell : TableCell
{
SerializedProperty sp;
public override void DrawCell(Rect rect)
{
if (sp != null)
{
sp.stringValue = EditorGUI.TextField(rect, GUIContent.none, sp.stringValue);
sp.serializedObject.ApplyModifiedProperties();
}
else
{
Debug.LogWarningFormat("Property not found: {0} -> {1}", sp.serializedObject.targetObject.name, sp.propertyPath);
}
}
public override string comparingValue
{
get
{
return GetPropertyValueAsString(sp);
}
}
public StringCell(SerializedProperty property)
{
this.sp = property;
}
}
@D-d-denzi
I just submitted a new version with a new column option: IgnoreAttributes. You can set this option to true for your properties that have attributes above them that mess with the display in the table.
So in your example, that would be:
[Table("shipName: IgnoreAttributes(true)", "xp")]
Let me know if it works for you.
It might take a week or two before the update gets approved, let me know if you need it more quickly.
@achan_unity
Strings marked with [TextArea] are rendered in multiline fields for me, but they do have an empty space on top
I will fix this case. Thanks for reporting.
This is great. Thanks.
Regarding the Sprite - I’d like to see if it is possible to show a preview of the Sprite as a small icon right in the Sprite Selector. It will make editing much easier.
Oh, I see, you mean in case you have a Sprite property in your elements.
Strangely, by default, Unity shows a preview for Texture2D’s but not for Sprites (see in SpriteRenderer for example: ), so that’s what will happen in the table too.
I will add a special Cell Type for that in the next version.
In the meantime, you can also create a custom attribute for that.
Add these 2 classes to your project.
using UnityEngine;
public class ImageAttribute : PropertyAttribute
{
public float height;
public ImageAttribute(float height)
{
this.height = height;
}
public ImageAttribute()
{
this.height = 80f;
}
}
using UnityEngine;
using UnityEditor;
[CustomPropertyDrawer(typeof(ImageAttribute))]
public class ImageAttributeDrawer : PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
ImageAttribute imageAttribute = (ImageAttribute)attribute;
return imageAttribute.height;
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
property.objectReferenceValue = (Sprite)EditorGUI.ObjectField(position, label, property.objectReferenceValue, typeof(Sprite), false);
property.serializedObject.ApplyModifiedProperties();
}
}
Then add [/I] before your Sprite declaration, and it will show up like that all the time, table or not.