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,220评论 6 13
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,262评论 4 61
  • 我们来先看效果图 概述 关于手机图片加载器,在当今像素随随便便破千万的时代,一张图片占据的内存都相当可观,作为高大...
    小熊_c37d阅读 2,369评论 0 9
  • 整个美利坚之行,忽冷忽热、又干又燥的气候,鼻炎没有犯。湿疹也在快回来的时候,消停了。 注意保暖是第一要务,湿疹之所...
    薇薇董阅读 208评论 0 0
  • 从一个长梦中醒来,枕边没有纸笔。我决定用备忘录来记载这一个辗转流离的梦。时间架空,本故事纯属虚构,若有雷同,还请见...
    桨声芦影阅读 389评论 1 1