コガネブログ

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

【Unity】【NGUI】UIWrapContentのInspectorにソート用のボタンを追加するエディタ拡張

using UnityEditor;
using UnityEngine;

[CanEditMultipleObjects]
[CustomEditor( typeof( UIWrapContent ), true )]
public sealed class UIWrapContentEditorCustom : UIWrapContentEditor
{
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        if ( GUILayout.Button( "Sort Based on Scroll Movement" ) )
        {
            var self = target as UIWrapContent;
            self.SortBasedOnScrollMovement();
        }
        if ( GUILayout.Button( "Sort Alphabetically" ) )
        {
            var self = target as UIWrapContent;
            self.SortAlphabetically();
        }
    }
}

f:id:baba_s:20161016201341p:plain