Unity插件 Odininspector 使用小記 (一)

Odin 是目前最牛的編輯器定制化工具,可以輕松完成屬性的可視化編輯.

開始使用

#if UNITY_EDITOR

    using Sirenix.Utilities.Editor;

#endif

基礎

  • Title
  • InfoBox
   [Title("Advanced List Customization")]
   [InfoBox("Using [ListDrawerSettings], lists can be customized in a wide variety of ways.")]
  • ReadOnly -- 只讀屬性
 [ReadOnly]
 public int[] ReadOnlyArray2 = new int[] { 1, 2, 3 };
  • PropertyOrder 屬性展示順序

    image

  • [TabGroup] 分組顯示


    image

進階

  • 校驗數據有效性


    Valid

    Required

Array

  • 下拉列表選擇


    image
  • Range 支持 array

        [Range(0, 1)]
        public float[] FloatRangeArray;
  • 設置列表自動分頁
     [ListDrawerSettings(NumberOfItemsPerPage = 5)]
     public int[] FiveItemsPerPage;
屏幕快照 2018-02-04 上午7.40.01.png
  • 為列表項設置標簽
[ListDrawerSettings(ShowIndexLabels = true, ListElementLabelName = "SomeString")]
屏幕快照 2018-02-04 上午7.43.50.png
  • 自定義顯示樣式和按鈕方法
        [ListDrawerSettings(OnBeginListElementGUI = "BeginDrawListElement", OnEndListElementGUI = "EndDrawListElement")]
        public SomeStruct[] InjectListElementGUI;

        [ListDrawerSettings(HideAddButton = true, OnTitleBarGUI = "DrawAddButton")]
        public List<int> CustomButtons;
#if UNITY_EDITOR

        private void BeginDrawListElement(int index)
        {
            SirenixEditorGUI.BeginBox(this.InjectListElementGUI[index].SomeString);
        }

        private void EndDrawListElement(int index)
        {
            SirenixEditorGUI.EndBox();
        }

        private void DrawAddButton()
        {
            if (SirenixEditorGUI.ToolbarButton(EditorIcons.Plus))
            {
                this.CustomButtons.Add(Random.Range(0, 100));
            }

            GUIHelper.PushGUIEnabled(GUI.enabled && this.CustomButtons.Count > 0);
            if (SirenixEditorGUI.ToolbarButton(EditorIcons.Minus))
            {
                this.CustomButtons.RemoveAt(this.CustomButtons.Count - 1);
            }
            GUIHelper.PopGUIEnabled();
        }

#endif
屏幕快照 2018-02-04 上午8.19.21.png
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • 國家電網公司企業標準(Q/GDW)- 面向對象的用電信息數據交換協議 - 報批稿:20170802 前言: 排版 ...
    庭說閱讀 11,123評論 6 13
  • 發現 關注 消息 iOS 第三方庫、插件、知名博客總結 作者大灰狼的小綿羊哥哥關注 2017.06.26 09:4...
    肇東周閱讀 12,200評論 4 61
  • 我們來先看效果圖 概述 關于手機圖片加載器,在當今像素隨隨便便破千萬的時代,一張圖片占據的內存都相當可觀,作為高大...
    小熊_c37d閱讀 2,351評論 0 9
  • 整個美利堅之行,忽冷忽熱、又干又燥的氣候,鼻炎沒有犯。濕疹也在快回來的時候,消停了。 注意保暖是第一要務,濕疹之所...
    薇薇董閱讀 193評論 0 0
  • 從一個長夢中醒來,枕邊沒有紙筆。我決定用備忘錄來記載這一個輾轉流離的夢。時間架空,本故事純屬虛構,若有雷同,還請見...
    槳聲蘆影閱讀 387評論 1 1