Skip to content

Editor that draws all lists/arrays in Unity Inspector as re-orderable by default.

License

Notifications You must be signed in to change notification settings

andeart/UnityLabs.ReorderableListEditor

Repository files navigation

UnityLabs.ReorderableListEditor

nuget-release nuget-dls
github-release github-dls

Editor that draws all lists/arrays in Unity Inspector as re-orderable by default.

ReorderableListEditor.gif

This is inspired by Valentin Simonov's blog article about reorderable lists, with additional tweaks and functionality.

This custom editor overrides Unity's default SerializedProperty drawing for arrays and lists.
The majority of the Editor code in this project is protected/virtual, allowing developers an easy to write custom editors that use/extend this reordering feature.

The above gif is the direct result of writing the following code in a project that includes this lib.

[Serializable]
public struct MyData
{
    [SerializeField]
    private string _name;
    [SerializeField] [Range (0f, 1f)]
    private float _floatInRange;
}

public class MainContext : MonoBehaviour
{
    [SerializeField]
    private int[] _integers;

    [SerializeField]
    private MyData[] _dataObjects;

    [SerializeField]
    private ScriptableObject[] _scriptableObjects;
}

Notice the absence of any specialised types or attributes. This also works with public fields that Unity auto-serializes, though I personally prefer to avoid those.

Installation and Usage

  • Download the Andeart.ReorderableListEditor.dll file from the NuGet page, or from the Github releases page.
  • Add this file anywhere in your Unity project. Any sub-directory under Assets will work- it does not need to be under an Editor folder.
  • Optional: Also drop the Andeart.ReorderableListEditor.pdb and Andeart.ReorderableListEditor.xml files in the same location if you're interested in debugging.
  • All of your serialized/public arrays/lists should be re-orderable by default now. Go build some magic.

Feedback

Please feel free to send merge requests, or drop me a message. Cheers!

About

Editor that draws all lists/arrays in Unity Inspector as re-orderable by default.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages