twsiyuan / unity-ReorderableListUtility

Help functions to build ReorderableList

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ReorderableListUtility

What is this

A wrapper function that easily build ReorderableList for array serailized property in Unity.

ReorderableList is a undocumented editor class that visualize list in UnityEditor.

See this post for more information.

This is build-in array editor

Build-in array editor

Visualized by Reorderable-list

Reorderable-list editor

Getting Started

Example editor Assets/Example/Editor/ShopMenuEditor.cs

Note: Test in Unity5.3.5f1

Example

Create ReorderableList

var property = this.serializedObject.FindProperty("MyArrayProperty");
var list = ReorderableListUtility.CreateAutoLayout(property);

Do Layout

// With foldout
ReorderableListUtility.DoLayoutListWithFoldout(list);

// Or original
list.DoLayoutList()

Create ReorderableList with custom headers

var list = ReorderableListUtility.CreateAutoLayout(
   property, 
  new string[] { "Column1", "Column2", "Column3" },
);

Or create ReorderableList with custom column widths

var list = ReorderableListUtility.CreateAutoLayout(
   property, 
   null,
   new float?[] { 100, 100, 100 },
);

Or combine them

var list = ReorderableListUtility.CreateAutoLayout(
   property, 
   new string[] { "Column1", "Column2", "Column3" },
   new float?[] { 100, 100, 100 },
);

Or specify last column width and auto adject others

var list = ReorderableListUtility.CreateAutoLayout(
   property, 
   new string[] { "Column1", "Column2", "ColumnLast" },
   new float?[] { null, null, 100 },
);

License

This project is licensed under the Apache License - see the LICENSE.md file for details

About

Help functions to build ReorderableList

License:Apache License 2.0


Languages

Language:C# 100.0%