Range Attribute:Unity自帶屬性,用于給一個數值創建一個滑動控件
using Sirenix.OdinInspector;
using UnityEngine;
public class RangeAttributeExample : MonoBehaviour
{
[Range(0, 10)]
public int Field = 2;
[InfoBox("Odin的PropertyRange屬性類似于Unity的Range屬性,但也適用于屬性。")]
[ShowInInspector, PropertyRange(0, 10)]
public int Property { get; set; }
[InfoBox("您還可以為最小值和最大值中的一個或兩個引用成員.")]
[PropertyRange(0, "Max"), PropertyOrder(3)]
public int Dynamic = 6;
[PropertyOrder(4)]
public int Max = 100;
}