How do check which enum value was selected?

I have this enum in one script:

	public enum TypeOfRotation
		public TypeOfRotation RotationType;

And then in another script I want set the value of elementNameProperty (a string) to be whatever was selected in the enum (SingleRotation or LoopedRotation). The following code doesn’t work and I don’t quite know how to achieve this.

RotationTimeline.elementNameProperty = RotationTimeline.GetItem(0).FindPropertyRelative("TypeOfRotation").enumNames;


Hi @alexanderameye, If I understand you correctly then you are looking for something like this

public static T ParseEnum<T>(string value)
    return (T) System.Enum.Parse(typeof(T), value, true);

public override void OnInspectorGUI()
    SerializedProperty property = RotationTimeline.serializedProperty.GetArrayElementAtIndex(0).FindPropertyRelative("RotationType");
    Rotations.RotationsChild.TypeOfRotation rotationType = ParseEnum<Rotations.RotationsChild.TypeOfRotation>(property.stringValue);
    if (rotationType == Rotations.RotationsChild.TypeOfRotation.SingleRotation)

    //Instead of checking the value of 'SingleRotation' here, I want it to check what element of the RotationType enum was selected
    // RotationTimeline.elementNameProperty = RotationTimeline.GetItem(0).FindPropertyRelative("SingleRotation").stringValue;


Lines were getting too long to read, I added the function ParseEnum<>() which returns an enum value from a string. I also broke everything down into multiple lines and added the if comparison statement.

I do mot know what Malee and Malee.Editor are as I did not have the associated scripts, so for testing purposes I had to comment out the uses statements and any code associated. I also had to add the uses statement

using UnityEditorInternal;

to use ReorderableList.