Property Range Attribute:屬性創(chuàng)建一個滑塊控件,以將屬性的值設置在指定范圍之間。這等效于Unity的Range屬性,但是此屬性可以同時應用于字段和屬性。
using Sirenix.OdinInspector;
using UnityEngine;
public class PropertyRangeAttributeExample : 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;
}