Unity插件之Odin 2.Inspector使用-GroupAndLayout

Unity插件之Odin 2.Inspector使用-GroupAndLayout

简介

Odin定义了很多的属性标签,通过这些属性标签很大程度上增强了编辑器功能,本文将详细介绍如下属性标签:

  • TableList
  • TabGroup
  • HorizontalGroup
  • VerticalGroup
  • FoldoutGroup
  • BoxGroup
  • ToggleGroup
  • InlineProperty
  • TitleGroup

声明

本文中的内容属于个人总结整理而来,个人水平有限,对于部分细节难免有理解错误及遗漏之处,如果您在阅读过程中有所发现,希望您能指正,同时文章中的部分内容也参考了其它大神的文章,如果文章中的内容侵犯了您的权益,表示非常歉意,请您指出,我将尽快修改。

如果您进行转载,请标明出处。

Unity插件之Odin 2.Inspector使用-GroupAndLayout(http://www.liyubin.com/articles/2019/03/26/1553609543968.html)

API详解



TableListAttribute

简介

对List和Array使用TableList属性标签,可以在面板中以表的形式进行绘制

API详解

  • Fields

    类 型 名 称 说 明
    int NumberOfItemsPerPage 设置一页中元素的数量。如果ShowPaging属性为True,设置此值将会覆盖Odin系统设置中的值
    bool IsReadOnly 设置table为只读,为True时会屏蔽掉所有编辑功能,比如添加、删除等,但是对于内部的元素还是可以修改其值的,与ReadOnlyAttribute有一定的不同
    int DefaultMinColumnWidth 设置一列的宽度,默认值为40.使用TableColumnWidthAttributes可以覆盖此值
    bool ShowIndexLabels 设置是否显示元素在列表或者数组中的下标位置
    bool DrawScrollView 设置是否绘制ScrollView
    int MinScrollViewHeight 设置出现滚动窗口时最小设置值,默认是350
    int MaxScrollViewHeight 设置出现滚动窗口最大设置值,默认是0
    bool AlwaysExpanded 设置是否展开
    bool HideToolbar 设置是否隐藏工具条,工具条上有添加、翻页等功能
    int CellPadding 设置间隔,默认是2
  • Properties

    Get/Set 类 型 名 称 描 述
    Get&Set bool ShowPaging 设置是否使用翻页功能,可以在Odin系统设置中设置此值
    Get bool ShowPagingHasValue 获取ShowPaging是否有设置过值
    Get&Set TextAlignment ScrollViewHeight 设置MinScrollViewHeight与MaxScrollViewHeight
  • Constructors

示例

Unity插件之Odin 2.Inspector使用-GroupAndLayout_第1张图片
Odin-TableListAttribute


TabGroupAttribute

简介

TabGroup属性标签继承自PropertyGroupAttribute,实现ISubGroupProviderAttribute接口,可以将不同的属性组织到不同的标签页中,从而能够更好显示

能过设置group组的名称,可以使用多个标签页,甚至可以嵌套使用。

API详解

  • Fields

    类 型 名 称 说 明
    string TabName 设置标签页的名称,相同的名称将会确定为在相同的标签中显示
    bool UseFixedHeight 设置所有的标签页是否使用相同的高度
    bool Paddingless
  • Properties

    Get/Set 类 型 名 称 描 述
    Get&Set List Tabs 所有标签页的名称
  • Constructors

    参 数 描 述
    string tab, bool useFixedHeight = false, int order = 0 将使用默认的group组名称,新建标签页
    string group, string tab, bool useFixedHeight = false, int order = 0 使用指定的group组名称创建标签页,对于同时显示多组标签页或者嵌套使用时,需要指定分组

示例

Unity插件之Odin 2.Inspector使用-GroupAndLayout_第2张图片
Odin-TabGroupAttribute


HorizontalGroupAttribute

简介

此属性标签继承自PropertyGroupAttribute,使用此属性标签后,可以将多个属性以水平排列的方式进行绘制,宽度值、左右边距等可以按百分比或者像素值进行设定,如果值0-1之间的值,则表示百分比,设置为0时表示自动设置宽度,否则将使用像素进行绘制。

可以通过指定不同的分组名称从而可以同时使用多组,也可以进行嵌套

API详解

  • Fields

    类 型 名 称 说 明
    float Width 设置宽度
    float MarginLeft 设置左边距
    float MarginRight 设置右边距
    float PaddingLeft 设置左侧空余
    float PaddingRight 设置右侧空余
    float MinWidth 设置最小宽度
    float MaxWidth 设置最大宽度
    string Title 设置标题,此标签将在水平布局器上方显示
    float LabelWidth 设置文本宽度,0表示自动设定
  • Properties

  • Constructors

    参 数 描 述
    string group, float width = 0, int marginLeft = 0, int marginRight = 0, int order = 0 各个参数的含义参见Fields中说明
    float width = 0, int marginLeft = 0, int marginRight = 0, int order = 0 各个参数的含义参见Fields中说明

示例

Unity插件之Odin 2.Inspector使用-GroupAndLayout_第3张图片
Odin-HorizontalGroupAttribute


VerticalGroupAttribute

简介

此属性标签继承自PropertyGroupAttribute,使用此属性标签后,可以将指定的属性或者其它属性标签分配好的组进行垂直布局

API详解

  • Fields

    类 型 名 称 说 明
    float PaddingTop 设置上面空余大小
    float PaddingBottom 设置下面空余大小
  • Properties

  • Constructors

    参 数 描 述
    string groupId, int order = 0 各个参数的含义参见Fields中说明,groupId代表不同的分组名称
    int order = 0 各个参数的含义参见Fields中说明

示例

Unity插件之Odin 2.Inspector使用-GroupAndLayout_第4张图片
Odin-VerticalGroupAttribute


FoldoutGroupAttribute

简介

此属性标签继承自PropertyGroupAttribute,使用此属性标签后,可通过折叠按钮对其管理的属性进行折叠或展开

API详解

  • Fields

    类 型 名 称 说 明
    bool Expanded 设置折叠标签的状态
  • Properties

    Get/Set 类 型 名 称 描 述
    Get&Set bool HasDefinedExpanded 判断Expanded是否有赋值
  • Constructors

    参 数 描 述
    string groupName, int order = 0 各个参数的含义参见Fields中说明

示例

Unity插件之Odin 2.Inspector使用-GroupAndLayout_第5张图片
Odin-FoldoutGroupAttribute


BoxGroupAttribute

简介

此属性标签继承自PropertyGroupAttribute,使用此属性标签后,可以将多个属性通过Box的形式在一起展示

API详解

  • Fields

    类 型 名 称 说 明
    bool ShowLabel 设置是否显示组的名称
    bool CenterLabel 设置标题文本是否居中显示,否则将会在左侧显示
  • Properties

  • Constructors

    参 数 描 述
    ----
    string group, bool showLabel = true, bool centerLabel = false, int order = 0 各个参数的含义参见Fields中说明

示例

Unity插件之Odin 2.Inspector使用-GroupAndLayout_第6张图片
Odin-BoxGroupAttribute


ToggleGroupAttribute

简介

此属性标签继承自PropertyGroupAttribute,使用此属性标签后,可以将一组属性统一管理,并且可以启用或者禁用此组属性

API详解

  • Fields

    类 型 名 称 说 明
    string ToggleGroupTitle 设置组的标题,如果为Null将使用ToggleMemberName的名称替代
    bool CollapseOthersOnExpand 设置同一组中当某个组展开时,是否折叠其它的组
  • Properties

    Get/Set 类 型 名 称 描 述
    Get string ToggleMemberName 返回指定的名称
  • Constructors

    参 数 描 述
    string toggleMemberName, int order = 0, string groupTitle = null toggleMemberName值为属性、字段或者方法的名称,其返回值代表着组是否启用
    string toggleMemberName, string groupTitle toggleMemberName值为属性、字段或者方法的名称,其返回值代表着组是否启用

示例

Unity插件之Odin 2.Inspector使用-GroupAndLayout_第7张图片
Odin-ToggleGroupAttribute


InlinePropertyAttribute

简介

使用此属性标签后,可以将属性的内容紧接着文本显示,则不再使用折叠标签显示。

PS:对于子类型,Unity默认会将其按折叠标签的样式显示,使用此标签可以使用文本直接显示

API详解

  • Fields

    类 型 名 称 说 明
    int LabelWidth 设置文本的宽度
  • Properties

  • Constructors

示例

Unity插件之Odin 2.Inspector使用-GroupAndLayout_第8张图片
Odin-InlinePropertyAttribute


TitleGroupAttribute

简介

此属性标签继承自PropertyGroupAttribute,使用此属性标签后,可以将多个属性绘制成一组,同时为其添加标题

API详解

  • Fields

    类 型 名 称 说 明
    string Subtitle 设置子标题内容
    TitleAlignments Alignment 设置标题的对齐方式
    bool HorizontalLine 设置标题下是否添加水平分隔线
    bool BoldTitle 设置标题是否加粗
    bool Indent 设置是否缩进
  • Properties

  • Constructors

    参 数 描 述
    string title, string subtitle = null, TitleAlignments alignment = TitleAlignments.Left, bool horizontalLine = true, bool boldTitle = true, bool indent = false, int order = 0

示例

Unity插件之Odin 2.Inspector使用-GroupAndLayout_第9张图片
Odin-TitleGroupAttribute


你可能感兴趣的:(Unity插件之Odin 2.Inspector使用-GroupAndLayout)