需要先定义,在类之外定义:
public enum ConveyorType
{
Metering,Straight// by default Metering=0, Straight =1;
}
然后,在属性中增加此类型的属性:
[Auto] SimplePropertyValue<ConveyorType> ConvType;
可以在代码中使用:
[Auto] void OnReset(Visual sender) {
int i = (int)ConveyorType.Metering;
print("Metering index is: " + i);
}
[Auto] void OnConvTypeUpdated(Visual sender, ConveyorType newValue, ConveyorType oldValue)
{
print("Old value: " + oldValue + " ======> " + " New value: " + newValue);
if (newValue == ConveyorType.Metering)
{
(sender as ConveyorVisual).Length = 1.2;
}
if (newValue== ConveyorType.Straight)
{
(sender as ConveyorVisual).Length = 3;
}
}