コガネブログ

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

【Unity】Unity 2020.2b 新機能 - デフォルトで配列やリストを Inspector で並べ替えられるようになった

概要

Unity 2020.2a では「Reorderable」属性を変数に適用すれば
配列やリストを Inspector で並べ替えられるようになりましたが、
Unity 2020.2b では「Reorderable」属性を適用しなくても
デフォルト動作で並び替えができるようになりました

using System.Collections.Generic;
using UnityEngine;

public class Example : MonoBehaviour
{
    public string[]    m_names;
    public Vector3[]   m_positions;
    public List<Color> m_colors;
}

f:id:baba_s:20200915121803g:plain

並び替えを無効化したい場合は下記のように
「NonReorderable」属性を適用します

using System.Collections.Generic;
using UnityEngine;

public class Example : MonoBehaviour
{
    [NonReorderable] public string[]    m_names;
    [NonReorderable] public Vector3[]   m_positions;
    [NonReorderable] public List<Color> m_colors;
}

f:id:baba_s:20200915121817p:plain