美文网首页
Odin Inspector 系列教程 --- Show In

Odin Inspector 系列教程 --- Show In

作者: 忆中异 | 来源:发表于2021-12-01 10:23 被阅读0次

Show In Inspector Attribute特性:用于任何成员,并在inspector中显示该值。请记住,ShowInInspector特性不会序列化任何内容; 这意味着您所做的任何更改都不会仅仅使用ShowInInspector属性进行保存。
如果需要序列化,需要配合SerializeField特性使用

image
完整示例代码
using Sirenix.OdinInspector;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ShowInInspectorExample : MonoBehaviour
{
    [ShowInInspector]
    private int myPrivateInt;

    [ShowInInspector]
    public int MyPropertyInt { get; set; }

    [ShowInInspector]
    public int ReadOnlyProperty
    {
        get { return this.myPrivateInt; }
    }

    [ShowInInspector]
    public static bool StaticProperty { get; set; }

    private void Start()
    {
        Debug.Log($"{MyPropertyInt}");
    }
}


更多教程内容详见:Unity 编辑器扩展工具 --- Odin Inspector 系列教程

链接:https://www.jianshu.com/p/f5ee50a9e726

相关文章

网友评论

      本文标题:Odin Inspector 系列教程 --- Show In

      本文链接:https://www.haomeiwen.com/subject/wyqbtrtx.html