Reorderable List from Generic List in Unity

By November 18, 2016Game Development, Unity

Since Unity 5.4 we have an undocumented feature: reorderable list and they are fantastic.

After reading this great blog post by Valentin Simonov I decided to tackle reordable lists in Unity myself.
After all, they truly present a much cleaner way to display your lists, with the added bonus of an add and remove button.

However, after struggling a bit to get a generic List of gameobjects to appear in the editor as a reorderable list, I decided to write this blog post.
As it is an undocumented feature, my guess is that quite some people could benefit from it. In the end, the result is fairly easy as you will see.

I do strongly suggest to read the original article as it covers the whole subjects to a great extent.

Create a reorderable List in Unity

Let’s imagine you have your base class, featuring a generic gameobject list

Creating the Editor Script:

(btw. I have quite a handy free tool for Unity to create an instant base for your editor scripts which you can find in the asset store:
Handy Editor Scripts or Handy Tools — Useful Hierarchy / Folder Structure / Instant Editor Scripts / Level Design Tools
While you are there check out some of my other tools, they might come in “handy” *coughs)

 

The result is a nice looking list which you can move around, and edit.
reorderable list

 

That is all you need to do, and if required, please find the code on github.
In conclusion, make sure to read the initial article for a clear and in-depth guide.

Cheers!

Leave a Reply