Show In Inspector Attribute特性:用于任何成員猿棉,并在inspector中顯示該值节吮。請(qǐng)記住,ShowInInspector特性不會(huì)序列化任何內(nèi)容; 這意味著您所做的任何更改都不會(huì)僅僅使用ShowInInspector屬性進(jìn)行保存瘪匿。
如果需要序列化跛梗,需要配合SerializeField特性使用
完整示例代碼
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}");
}
}