Search Unity

EnumPopup... what can be wrong?

Discussion in 'Scripting' started by nandobang, Apr 6, 2010.

  1. nandobang

    nandobang

    Joined:
    Apr 6, 2010
    Posts:
    26
    Hello my friends,

    I'm writing a custom editor here, and I need the EditorGUILayout.EnumPopup to cut things down.
    The problem is that I can't get it to work:

    "Cannot implicitly convert type `System.Enum' to `FrameEvent.FrameEventType'. An explicit conversion exists (are you missing a cast?)"

    I've tried casting it;
    My enum (FrameEventType) is contained in a class, and it is public;

    Here's where I'm calling it:

    Code (csharp):
    1.  
    2. FrameEventDispatcher fed = Selection.activeGameObject.GetComponent<FrameEventDispatcher>();
    3.  
    4. _gui_itensIndex = EditorGUILayout.Popup(_gui_itensIndex, optionsLabels);
    5.  
    6. /* This is the error line
    7. eventType is my enum;
    8. events is an array of a custom class that contains my enum;
    9. */
    10. fed.events[_gui_itensIndex].eventType = EditorGUILayout.EnumPopup(fed.events[_gui_itensIndex].eventType, GUI.skin.textField);
    11.  
    I could do this using the normal popup, but this would save me some time, plus the knowledge.

    If anyone has any tips on using the EnumPopup, I'll be very gratefull.

    Thank you!
     
  2. nandobang

    nandobang

    Joined:
    Apr 6, 2010
    Posts:
    26
    Solved it!

    I was missing a cast of my own Enum. :oops:

    Hope this can be of any use to somene, at least.