zoukankan      html  css  js  c++  java
  • Unity Odin笔记

    https://odininspector.com/tutorials

    https://blog.csdn.net/su9257/article/details/103159984

    https://odininspector.com/attributes

    总结:

      1.标签化管理

      2.自定义绘制。比如 OnInspectorGUI和CustomDraw等 可以自定义变量的绘制。

      3.Group可以进行区域属性的划分,子属性不需要写N多标签。

    具体想要什么 用的时候再查阅吧。

    1.Assets Only Attribute

    https://www.jianshu.com/p/194081e24e65

    • AssetsOnly: 点击需要序列化的资源字段时,在出现的弹窗中只有Project中的资源文件,不会出现Hierachy(场景)的资源
    • SceneObjectsOnly: 点击需要序列化的资源字段时,在出现的弹窗中只有Hierachy中的资源文件,不会出现Project中的资源
      注意:例如:预制体等资源在Scene或者Project中都含有,出现的弹窗中也都会含有对应的资源

    2.Custom Value Drawer Attribute

    https://www.jianshu.com/p/1c4e85a83e3c

    Custom Value Drawer Attribute 特性,允许用户自定义一个绘制方法  (这个好,可以散列的对变量进行自定义显示操作。和数据逻辑和EditorGUILayout关联)

        public float Max = 100, Min = 0;
    
        [CustomValueDrawer("MyStaticCustomDrawerStatic")]
        public float CustomDrawerStatic;
        private static float MyStaticCustomDrawerStatic(float value, GUIContent label)
        {
            return EditorGUILayout.Slider(label, value, 0f, 10f);
        }
    
        [CustomValueDrawer("MyStaticCustomDrawerInstance")]
        public float CustomDrawerInstance;
    
        private float MyStaticCustomDrawerInstance(float value, GUIContent label)
        {
            return EditorGUILayout.Slider(label, value, this.Min, this.Max);
        }
    
        [CustomValueDrawer("MyStaticCustomDrawerArray")]
        public float[] CustomDrawerArray = new float[] { 3f, 5f, 6f };
    
    
        private float MyStaticCustomDrawerArray(float value, GUIContent label)
        {
            return EditorGUILayout.Slider(value, this.Min, this.Max);
        }

     3.Delayed Property Attribute

    1.变量更改的的回调 OnValueChanged  2.Delay方式让回调在鼠标离开选项框在callback    3.Delayed  DelayedProperty 后者可用于属性值

        // Delayed and DelayedProperty attributes are virtually identical...
        [Delayed]
        [OnValueChanged("OnValueChanged")]
        public int DelayedField;
    
        // ... but the DelayedProperty can, as the name suggests, also be applied to properties.
        [ShowInInspector, DelayedProperty]
        [OnValueChanged("OnValueChanged")]
        public string DelayedProperty { get; set; }
    
        private void OnValueChanged()
        {
            Debug.Log("Value changed!");
        }

    4.Detailed Info Box Attribute

    在Inspector面板中绘制一个信息面板,添加对应标题和详细信息描述,点击时可以显示出对应填写的详细信息   https://www.jianshu.com/p/ee83f0c151e9

          //
            // 摘要:
            //     Displays a message box with hideable details.
            //
            // 参数:
            //   message:
            //     The message for the message box.
            //
            //   details:
            //     The hideable details of the message box.
            //
            //   infoMessageType:
            //     Type of the message box.   哪种类型的图标提示 
            //
            //   visibleIf:
            //     Optional name of a member to hide or show the message box.   自定义是否显示这个Box信息
            public DetailedInfoBoxAttribute(string message, string details, InfoMessageType infoMessageType = InfoMessageType.Info, string visibleIf = null);

    5.Enable GUIAttribute

    把显示灰色的不置灰,感觉用不到啊

    6.GUIColor Attribute

    1.RGB  2.自定义方式 3.@字符串方式实现2的方式

    7.Hide Label Attribute

    用于任何属性。使用此选项可隐藏Inspector中的属性标签。

    8.Property Order Attribute

    PropertyOrder特性:用于任何属性,并允许对属性进行排序。使用此选项可以定义属性的显示顺序。

     9.Property Space Attribute

    PropertySpace特性:与Unity的现有Space属性具有相同的功能,但可以应用于任何属性而不仅仅是字段;而且还可以控制与前后字段的间距

    10.Read Only Attribute

    就是以灰态的形式展示

     11.Required Attribute

    用于任何对象属性,如果对应属性没有赋值,则在检查器中出现对应的提示消息。

    12.Show In Inspector Attribute

    如果需要序列化,需要配合SerializeField特性使用

    [ShowInInspector]
    private int myPrivateInt;
    
    [ShowInInspector]  //没与序列化的属性也可以显示
    public int MyPropertyInt { get; set; }
    
    [ShowInInspector]
    public int ReadOnlyProperty
    {
        get { return this.myPrivateInt; }
    }
    
    [ShowInInspector] //static成员的显示
    public static bool StaticProperty { get; set; }
    [SerializeField, HideInInspector]
    private int evenNumber;
    
    [ShowInInspector]
    public int EvenNumber
    {
        get { return this.evenNumber; }
        set { this.evenNumber = value - (value % 2); }
    }

    13.Searchable Attribute

    搜索功能, 作用域比较灵活, 可以在独立的属性或者整体类上。

    14.Title Attribute

     用于在属性上方生成粗体标题。  主标题、副标题、是否有分割线、是否粗体

      [Title("Non bold title", "With no line seperator", horizontalLine: false, bold: false)]

    15.Type Filter Attribute

     https://www.jianshu.com/p/6b829180daef

     对输入的value 进行自定义过滤,只显示需要的类型

    16.Type Info Box Attribute

    TypeInfoBox特性:将信息框添加到Inspector中类型的最顶部。使用此选项可将信息框添加到Inspector中类的顶部,而无需同时使用PropertyOrder和OnInspectorGUI属性(InfoBox的顶部版?)
    链接:https://www.jianshu.com/p/5ef964db2740

    17.Validate Input Attribute

    无效的输入,进行提示。(可自定义什么是有效。比如10.Required  Attribute 要求有输入才有效)

        [ValidateInput("HasMeshRendererDynamicMessageAndType", "对应的函数中已经有消息和类型,所以这个默认消息和类型已经没用")]
        public GameObject DynamicMessageAndType;
    
        [InfoBox("Change GameObject value to update message type", InfoMessageType.Info)]
        public InfoMessageType MessageType;
        private bool HasMeshRendererDynamicMessageAndType(GameObject gameObject, ref string errorMessage, ref InfoMessageType? messageType)
        {
            if (gameObject == null) return true;
    
            if (gameObject.GetComponentInChildren<MeshRenderer>() == null)
            {
                errorMessage = """ + gameObject.name + "" 要有一个 MeshRenderer 组件";//如果设置消息,则默认消息会被覆盖
                messageType = this.MessageType;//如果设置消息类型,则默认消息类型会被覆盖
                return false;
            }
            return true;
        }

    18.Value Dropdown Attribute 

    https://www.jianshu.com/p/72bbece66f5d

    1.MemberName,也是唯一一个有参构造函数需要的属性,有两种形式的Drop下拉条,一种是直接数值的,另一种是Key-Value形式的

    2.【SortDropdownItems】默认为false 开启后为下拉列表为根据Key升序排序

    3.【DropdownTitle】给下来条提供一个标题

    4.【DropdownHeight】下拉条高度 【DropdownWidth】下拉条的宽度

    5.【FlattenTreeView】是否使用平铺的树形视图
    6.【DoubleClickToConfirm】需要双击才能确地选中的内容

    7.【HideChildProperties】是否隐藏此类型所含有的属性信息

    8.【AppendNextDrawer】下拉条变成一个小的选择器,代替原有的宽型下拉条
    9.【DisableGUIInAppendedDrawer】配合AppendNextDrawer使用,显示的数值为灰度状态,达到不可更改数值的目的
    10.【ExpandAllMenuItems】下拉条里面的条目是否全部展开
    11.【IsUniqueList】在添加的列表Item前面添加勾选框,可以一次性勾选多个Item并添加
    12.【ExcludeExistingValuesInList】添加列中不会显示已经选中的Item
    13.【DisableListAddButtonBehaviour】禁用下拉列表,以弹窗的形式弹出
    14.【DrawDropdownForListElements】已经添加的Item不会再出现Item下拉表(和12有什么区别?)
    15.【NumberOfItemsBeforeEnablingSearch】查过指定数量的Item则出现搜索框。默认是10。

    19.Asset List Attribute

    针对一次性多个List和Array选择

      AssetList:创建一个指定类型的列表
    【Path】根据指定筛选资源的路径
    【AutoPopulate】符合规则的自动添加到List中 ,设置为true则自动填充符合规则的资源,false为只显示不填充
    【LayerNames】指定layer层过滤
    【AssetNamePrefix】以资源名称的前缀作为筛选条件
    【Tags】以资源的tag作为筛选条件,可用,符号分隔多个Tag
    【CustomFilterMethod】自定义过滤函数

    20.Asset Selector Attribute

    在对象字段旁边添加一个小按钮,该按钮将向用户显示资产下拉列表,以便从属性中进行选择。(IsUniqueList可进行多选)

    【AssetSelector】添加到对应的字段上即可
    【FlattenTreeView】是否开启树状图
    【Paths】单路径或多路径查找
    【Filter】自定义过滤条件
    【DisableListAddButtonBehaviour】开启后加号不会出现树形下拉条以弹窗形式出现
    【DrawDropdownForListElements】控制已经添加的Item是否含有下拉列表
    【ExcludeExistingValuesInList】去除已经含有的Item
    【IsUniqueList】开启列表勾选模式(这个关键字在Odin的很多特性中都有)
    【ExpandAllMenuItems】下拉列表是否强制展开(这个关键字在Odin的很多特性中都有)
    【DropdownTitle】下拉列表标题

    21.Child Game Objects Only Attribute

    用于Components和GameObject字段,并将在对象字段旁边添加一个小按钮,该按钮将在所有子游戏对象中搜索可分配对象,并将其显示在下拉列表中供用户选择。

    【ChildGameObjectsOnly】获取包括自己在内以的可用节点
    【IncludeSelf】是否包含自己的节点

     22.Color Palette Attribute

    调色板相关

    23.Display As String Attribute

    用于任何属性,对应的值在检查器中以文本形式显示字符串。如果属性的值要在检查器中显示字符串,但不允许进行任何编辑,请使用此选项。

    24.File Path Attribute

    字符串属性

        [FilePath(ParentFolder = "Assets/Resources")]
        public string ResourcePath;   //ParentFolder默认打开到Assets/Resources相对路径下
        [FilePath(Extensions = "cs")]
        [BoxGroup("Conditions")]
        public string ScriptFiles; //Extensions默认选择的是cs文件
    // By setting AbsolutePath to true, the FilePath will provide an absolute path instead.
        [FilePath(AbsolutePath = true)]//是否绝对路径
        [BoxGroup("Conditions")]
        public string AbsolutePath; 
    
        // FilePath can also be configured to show an error, if the provided path is invalid.
        [FilePath(RequireExistingPath = true)]//没值就显示大大的提醒
        [BoxGroup("Conditions")]
        public string ExistingPath;
    
        // By default, FilePath will enforce the use of forward slashes. It can also be configured to use backslashes instead.
        [FilePath(UseBackslashes = true)]//反斜杠
        [BoxGroup("Conditions")]
        public string Backslashes;
    
        // FilePath also supports member references with the $ symbol.
        [FilePath(ParentFolder = "$DynamicParent", Extensions = "$DynamicExtensions")]//动态定义父节点和扩展文件类型
        [BoxGroup("Member referencing")]
        public string DynamicFilePath;
    
        [BoxGroup("Member referencing")]
        public string DynamicParent = "Assets/Plugins/Sirenix";
    
        [BoxGroup("Member referencing")]
        public string DynamicExtensions = "cs, unity, jpg";
    
        // FilePath also supports lists and arrays.
        [FilePath(ParentFolder = "Assets/Plugins/Sirenix/Demos/Odin Inspector")]
        [BoxGroup("Lists")]
        public string[] ListOfFiles;

    25.Folder Path Attribute

     用于字符串字段,并为目录路径提供接口。

    26.Inline Editor Attribute

    InlineAttribute用于任何属性或字段,其类型继承自UnityEngine.Object。这包括组件和资产等。

    unity自带的详细编辑

     27.Hide In Inline Editors Attribute

    在属性对象的Inline编辑模式中隐藏不需要绘制的属性

    27.Enum Paging Attribute

    Draws an enum selector in the inspector with next and previous buttons to let you cycle through the available values for the enum property.

    [EnumPaging, OnValueChanged("SetCurrentTool")]
    [InfoBox("Changing this property will change the current selected tool in the Unity editor.")]
    public UnityEditor.Tool sceneTool;
    
    private void SetCurrentTool()
    {
        UnityEditor.Tools.current = this.sceneTool;
    }

    28.Table List Attribute

    https://odininspector.com/attributes/table-list-attribute

    Renders lists and arrays in the inspector as tables.

    [TableList(ShowIndexLabels = true)]

    [TableList(DrawScrollView = true, MaxScrollViewHeight = 200, MinScrollViewHeight = 100)]

    [TableList(AlwaysExpanded = true, DrawScrollView = false)]

    [TableList(ShowPaging = true)]

    29.Table Matrix Attribute

    绘制二维数组

    30.Hide In Tables Attribute

    TableList特性中隐藏对应的属性绘制的Inline

    31.Hide Mono Script Attribute

    隐藏系统Script属性的显示

    32.Multi Line Property Attribute

    允许用户在多行文本框中编辑字符串。

      [Multiline(10)]
      [MultiLineProperty(10)]

    33.Preview Field Attribute

    绘制一个方形ObjectField,它呈现UnityEngine.Object类型的预览。此对象字段还添加了对拖放的支持
      [PreviewField(150, ObjectFieldAlignment.Right)]

    34.Toggle Attribute

    控制属性是否可编辑

    Toggle is used on any field or property, and allows to enable or disable the property in the inspector. Use this to create a property that can be turned off or on.


    35.Toggle Left Attribute

    Draws the checkbox before the label instead of after.

    [InfoBox("Draws the toggle button before the label for a bool property.")]
    [ToggleLeft]
    public bool LeftToggled;
    
    [EnableIf("LeftToggled")]
    public int A;
    
    [EnableIf("LeftToggled")]
    public bool B;
    
    [EnableIf("LeftToggled")]
    public bool C;

    36.Button Attribute

    用于为一个方法在检查器中绘制一个触发该方法的功能按钮


    37.Enum Paging Attribute

    使用下一个和上一个按钮绘制枚举选择器,以便循环访问枚举属性的可用值

     38.Enum Toggle Buttons Attribute

    在水平按钮组中绘制枚举而不是下拉列表。

    39.Inline Button Attribute

    用于将一个按钮(函数)添加到属性的末尾。


    40.Box Group Attribute

    可用于任何属性,并将该属性组织在一个Box中。使用它可以在检查器中清晰地组织相关值。

    41.Title Group Attribute

    标题Group,将对应的成员划分
    可设置 副标题、标题对齐方式、子节点是否相对缩进、是否隐藏横线


    42.Foldout Group Attribute

    可用于任何属性,并将属性组织为折叠。使用它来组织属性,并允许用户隐藏当前与他们不相关的属性。

    expanded 标记为初始是否展开的。

     43.Horizontal Group Attribute

    1.层级关系是耦合的,可以避免在每个属性上都要重新写一遍。   2.MarginLeft、MarginRight(左右边距)、PaddingLeft(内边距)、PaddingRight(组与组的边距)、MinWidth与MaxWidth间距,设置Title标题

        [Button(ButtonSizes.Large)]
        [FoldoutGroup("Buttons in Boxes")]
        [HorizontalGroup("Buttons in Boxes/Horizontal")]
        [BoxGroup("Buttons in Boxes/Horizontal/One")]
        public void Button1() { }
    
        [Button(ButtonSizes.Large)]
        [BoxGroup("Buttons in Boxes/Horizontal/Two")]
        public void Button2() { }
    
        [Button]
        [HorizontalGroup("Buttons in Boxes/Horizontal", Width = 60)]
        [BoxGroup("Buttons in Boxes/Horizontal/Double")]
        public void Accept() { }
    
        [Button]
        [BoxGroup("Buttons in Boxes/Horizontal/Double")]
        public void Cancel() { }

    44.Tab Group Attribute


    可用于任何属性,并将属性组织到不同的选项卡中。使用它来组织不同的值,以使清洁检查器变得易于使用。
    也可以为选项卡指定对应的组
    https://www.jianshu.com/p/997e58be508a

    45.Vertical Group Attribute

    结合 Horizontal 可以达到二维的效果。 

    46.Toggle Group Attribute

    ToggleGroup用于任何字段,并创建一组可切换的选项。使用此选项可以创建可以启用或禁用的选项。
    也可以以制定toggle group的标题,或者通过$特殊标识符引用一个成员的值作为标题
    如果制定的toggle为class结构,需要添加Serializable特性,toggle标题默认为此类的名称,且继承关系的父类结构同样可以绘制在检查器面板上

    47.Button Group Attribute


    用于可用于任何实例函数,并将按钮添加到组织为水平组的检查器中。使用此按钮可以将多个按钮组织在一个整齐的水平组中。

    48.Responsive Button Group Attribute

    将按钮分组到一个组中,该组将根据可用布局空间的大小来定位和调整按钮的大小。


    以上,通过Group的概念,归类、通过名称划分父子层级



    49.Dictionary Drawer Settings Attribute

    【KeyLabel和ValueLabel】自定义标签
    【DictionaryDisplayOptions】控制value默认以折叠还是展开形式显示

    50.List Drawer Settings Attribute

    将[Range]属性应用于此列表,代替传统的float形式
    不同方式的只读方式
    数据结构的数组或列表
    自定义page每页的个数   [ListDrawerSettings(NumberOfItemsPerPage = 5)]
    显示对应元素的索引和指定其元素的标签  
       [ListDrawerSettings(ShowIndexLabels = true, ListElementLabelName = "SomeString")]
    禁止拖拽item,禁止翻页,禁止显示item个数
     [ListDrawerSettings(DraggableItems = false, Expanded = false, ShowIndexLabels = true, ShowPaging = false, ShowItemCount = false, HideRemoveButton = true)]
    【OnBeginListElementGUI】【OnEndListElementGUI】在每个列表元素的前后调用一个函数,并传入对应元素的索引
    使用它将自定义GUI行为注入到列表的标题栏中。
        [ListDrawerSettings(OnTitleBarGUI = "DrawRefreshButton")]
        public List<int> CustomButtons;
        private void DrawRefreshButton()
        {
            if (SirenixEditorGUI.ToolbarButton(EditorIcons.Refresh))
            {
                Debug.Log(this.CustomButtons.Count.ToString());
            }
        }
    【CustomAddFunction 】覆盖将对象添加到列表的默认行为。如果引用的成员返回列表类型元素,则将对每个选定对象调用该元素一次。如果引用的方法返回void,那么不管选择了多少对象,它都只会被调用一次
       [ListDrawerSettings(CustomAddFunction = "CustomAddFunction")]
        public List<int> CustomAddBehaviour;
        private int CustomAddFunction()
        {
            return this.CustomAddBehaviour.Count+100;
        }
    链接:https://www.jianshu.com/p/a7a403fb2541
     

    51.Table List Attribute

     将列表和数组呈现为表。

    【ShowIndexLabels】设置为True,则为每个元素绘制一个标签,其中显示元素的索引。
    【DrawScrollView 】为True,为table添加一个滚动条,并设置滚动条最大高度(MaxScrollViewHeight )和最小高度(MinScrollViewHeight )
    【ShowPaging】设置为True,则绘制一个翻页的选项 【NumberOfItemsPerPage】则设置每个分页含有的Item数量,默认15个
    • 【IsReadOnly】在检查器中不可修改
    • 【HideToolbar】隐藏翻页等工具
    • 【CellPadding】每个Item及属性的间隔
    • 【ScrollViewHeight】固定滚动条高度
    • 【MinScrollViewHeight】最小滚动条高度
    • 【MaxScrollViewHeight】最大滚动条高度
    链接:https://www.jianshu.com/p/c2782da859c8

    52.Table Matrix Attribute

    https://www.jianshu.com/p/9ef30570309e

    用于进一步指定Odin应如何绘制二维数组。

    HorizontalTitle:提供一个横向的标题 VerticalTitle :提供一个纵向的标题 SquareCells:为True,则其他的cell的宽高将于第一个cell的宽度相等
    【IsReadOnly 】为true,则不能调整矩阵的顺序
    【Transpose】作用起到一个顺序调到的效果
    其他辅助效果 ResizableColumns:是否可以通过鼠标调整列的宽度 RowHeight:固定行高度
        [PropertySpace(40)]
        [ShowInInspector, DoNotDrawAsReference]
        [TableMatrix(HorizontalTitle = "Transposed Custom Cell Drawing", DrawElementMethod = "DrawColoredEnumElement", ResizableColumns = true, RowHeight = 16, Transpose = true)]//Transpose顺序颠倒
        public bool[,] Transposed { get { return CustomCellDrawing; } set { CustomCellDrawing = value; } }
    
        private static bool DrawColoredEnumElement(Rect rect, bool value)
        {
            if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition))
            {
                value = !value;
                GUI.changed = true;
                Event.current.Use();
            }
    
            UnityEditor.EditorGUI.DrawRect(rect.Padding(1), value ? new Color(0.1f, 0.8f, 0.2f) : new Color(0, 0, 0, 0.5f));
    
            return value;
        }

    53.Table Column Width Attribute

    TableColumnWidth属性用于进一步自定义使用“ TableListAttribute” 绘制的表中的列的宽度。

    55.Value Dropdown Attribute

    自定义Dropdown的属性 , 还可以自定义下拉list的数据来源

    https://odininspector.com/attributes/value-dropdown-attribute
    [ValueDropdown("GetAllSceneObjects", IsUniqueList = true, DropdownTitle = "Select Scene Object", DrawDropdownForListElements = false, ExcludeExistingValuesInList = true)]
    public List<GameObject> UniqueGameobjectListMode2;
    private static IEnumerable GetAllSceneObjects()
    {
        Func<Transform, string> getPath = null;
        getPath = x => (x ? getPath(x.parent) + "/" + x.gameObject.name : "");
        return GameObject.FindObjectsOfType<GameObject>().Select(x => new ValueDropdownItem(getPath(x.transform), x));
    }
    
    private static IEnumerable GetAllScriptableObjects()
    {
        return UnityEditor.AssetDatabase.FindAssets("t:ScriptableObject")
            .Select(x => UnityEditor.AssetDatabase.GUIDToAssetPath(x))
            .Select(x => new ValueDropdownItem(x, UnityEditor.AssetDatabase.LoadAssetAtPath<ScriptableObject>(x)));
    }
    
    


    Custom Context Menu Attribute

    Custom Context Menu Attribute:可用于任何属性,并将自定义选项添加到属性的上下文菜单。当您要将自定义操作添加到属性的上下文菜单时,请使用此选项。
     [CustomContextMenu("Say Hello/菜鸟海澜", "SayHelloFunction")]

    Disable Context Menu Attribute

    用于任何属性,并禁用该属性的上下文菜单。如果您不希望属性使用上下文菜单,请使用此选项。


    Draw With Unity Attribute

     [InfoBox("如果你曾经遇到过Odin属性的问题,那么使用DrawWithUnity")]

     Indent Attribute

     用于缩进可用于任何属性,并将属性的标签向右移动。使用它可以清楚地组织检查器中的属性。

      [Indent(3)]

    Info Box Attribute

    【InfoBox】添加不同提示类型的文本框
    [InfoBox("Warning info box.", InfoMessageType.Warning)]

    Inline Property Attribute

     用于将类型的内容放置在标签旁边,而不是呈现在折叠中。

     https://www.jianshu.com/p/17e19ba03065

    On Inspector GUIAttribute

     [OnInspectorGUI("DrawPreview", append: true)]

    只要检查器代码正在运行,它将调用指定的函数。使用它为对象创建自定义InspectorGUI。(这个常用)


    On Value Changed Attribute

     [OnValueChanged("CreateMaterial")]
        public Shader Shader;
     

    Property Tooltip Attribute

    将属性悬停在检查器中时创建工具提示。用它来解释目的或如何使用属性。

     [PropertyTooltip("放在属性上显示对应的悬停提示.")]


     Suffix Label Attribute

    属性在属性的末尾绘制一个标签。用它来传达有关属性的意图
    [SuffixLabel("Prefab")]
     

    Enable If Attribute

    这个特性的效果主要是当指定条件满足时,启用对应的属性,默认传入的参数为对应属性的名称,如果为True或者不为null时,启用对应属性
     [EnableIf("SomeObject")]
    EnumToggleButtons 可以用来制作选择一个的button


     Hide If Attribute

    Show If Group Attribute

    EnableIf的集合模式。


    Show In Inline Editors Attribute

    Show In Inline Editors Attribute:用于在Inline中显示对应的属性

    [ShowInInlineEditors]
        public string ShownInInlineEditor;
    
        [HideInInlineEditors]//在绘制的里面不显示
        public string HiddenInInlineEditor;
    
        [DisableInInlineEditors]//显示但是是灰态
        public string DisabledInInlineEditor;

    Hide In Play Mode Attribute

    在Play模式下隐藏对应属性
    
    
     [HideInPlayMode]

    Disable In Non Prefabs Attribute

    用于当属性所在的组件在非预制体上面时,禁用对应的属性




     Max Value Attribute

    它将字段的值限制为最大值。使用此定义字段的最大值。

      [MaxValue(0)]

    Min Max Slider Attribute

    用于绘制一个特殊的滑块,用户可以用来指定最小值和最大值之间的范围。使用Vector2,其中x为最小值,y为最大值。
     [MinMaxSlider(-10, 10)]

    Progress Bar Attribute

    https://www.jianshu.com/p/4c1a57b13479

        // 最小和最大属性也支持带有$符号的属性表达式.
        [BoxGroup("Dynamic Range")]
        [ProgressBar("Min", "Max")]
        public float DynamicProgressBar = 50;
    
        [BoxGroup("Dynamic Range")]
        public float Min;
    
        [BoxGroup("Dynamic Range")]
        public float Max = 100;
     

    Property Range Attribute

    属性创建一个滑块控件,以将属性的值设置在指定范围之间。这等效于Unity的Range属性,但是此属性可以同时应用于字段和属性。

     [InfoBox("Odin的PropertyRange属性类似于Unity的Range属性,但也适用于属性.")]
        [ShowInInspector, PropertyRange(0, 10)]
        public int Property { get; set; }
     

    Wrap Attribute

    类似: Mathf.PingPong  
     [Wrap(0f, 100f)]
        public int IntWrapFrom0To100;



    改变自己
  • 相关阅读:
    E. Paired Payment 题解(多维最短路)
    九峰与子序列 题解(dp+hash)
    魏迟燕的自走棋 题解(并查集+思维)
    unix学习资料
    Tomcat > Cannot create a server using the selected type
    myeclipse使用hibernate正向工程和逆向工程
    jira的破解
    jsp:useBean用法
    java一个多线程的经典例子
    head first系列PDF资源
  • 原文地址:https://www.cnblogs.com/sun-shadow/p/15111419.html
Copyright © 2011-2022 走看看