Version: 2021.3
言語: 日本語
public string[] enumNames ;

説明

enum プロパティーの列挙型名

using UnityEditor;
using UnityEngine;

public enum ExampleEnum { ValueFirst = 1, ValueSecond = 2, ValueThird = 3, }

public class EnumExample : ScriptableObject { public ExampleEnum MyEnum = ExampleEnum.ValueSecond;

[MenuItem("Example/SerializedProperty Enum API")] static void Example() { EnumExample obj = ScriptableObject.CreateInstance<EnumExample>(); SerializedObject serializedObject = new SerializedObject(obj); SerializedProperty enumProperty = serializedObject.FindProperty("MyEnum");

//MyEnum value: 2 //Name of current value: ValueSecond //DisplayName: Value Second Debug.Log("MyEnum value: " + enumProperty.intValue + "\nName of current value: " + enumProperty.enumNames[enumProperty.enumValueIndex] + "\nDisplayName: " + enumProperty.enumDisplayNames[enumProperty.enumValueIndex]); } }