コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】Unity 標準よりも便利で使いやすい ReorderableList「Reorderable List」紹介

はじめに

「Reorderable List」は、Unity 標準よりも便利で使いやすい ReorderableList です

使用例

f:id:baba_s:20180312111405g:plain

f:id:baba_s:20180312111552g:plain

使い方

using Malee;
using System;
using System.Collections.Generic;
using UnityEngine;

public class Example : MonoBehaviour
{
    public List<ExampleChild> list1;

    [Reorderable] public ExampleChildList list2;
    [Reorderable] public ExampleChildList list3;
    [Reorderable] public StringList       list4;
    [Reorderable] public VectorList       list5;

    [Serializable]
    public class ExampleChild
    {
        public string name  ;
        public float  value ;
    }

    [Serializable]
    public class ExampleChildList : ReorderableArray<ExampleChild> { }

    [Serializable]
    public class StringList : ReorderableArray<string> { }

    [Serializable]
    public class VectorList : ReorderableArray<Vector4> { }
}

上記のようなコードを記述して使用します