EditorGUI.Popup Use of unnasigned local variable

I’ve got a simpe EditorGUI.Popup set up in my editor, but I can’t seem to find a way to assign the variable correctly.

string[] formOptions = new string[]
    {
    "Creature","Spell","Trap" 
    };

    int formSelection = EditorGUI.Popup(new Rect(position.x, position.y + 20,
        position.width * 0.9f, EditorGUIUtility.singleLineHeight),
        "Type of Card:", formSelection , formOptions);

The formSelection is throwing a Use of unnasigned local variable and if I make another variable to replace formSelection with, the Popup won’t change my selection.

I’m sure it’s not a very complicated issue, but I can’t find the information in C# anywhere, only JavaScript which I’d rather not delve into.

Save your formSelection as an instance field on your class.

int m_FormSelection;
...
void OnGUI ()
{
    ...
    m_FormSelection = EditorGUI.Popup(new Rect(position.x, position.y + 20,
        position.width * 0.9f, EditorGUIUtility.singleLineHeight),
        "Type of Card:", m_FormSelection, formOptions);
    ...
}