Editor Window Menu Buttons

Does anyone know how I can make buttons disappear and add a new list of them like a menu in the editor? I rather not use toggle because of the transparency thing. This is what I have in my Editor Script:

import System.Collections.Generic;
class MyEditor extends EditorWindow{
    @MenuItem("Window/My Editor %i")
  
    static function Init(){
        var ink :MyEditor = ScriptableObject.CreateInstance.<MyEditor>();
        ink.Show();
    }
    function OnGUI(){
    var mainMenu: boolean = true;
    var conditionsMenu : boolean = false;
    var eventsMenu : boolean = false;
        if(mainMenu){
            if(GUILayout.Button("Conditions...", GUILayout.Width(200), GUILayout.Height(20))){
                Debug.Log("Conditions menu is open...");
                conditionsMenu = true;
                mainMenu = false;
            }
        }
        if(conditionsMenu){
            if(GUILayout.Button("Trigger", GUILayout.Width(200), GUILayout.Height(20))){
                Debug.Log("Conditions menu is open...");
            }  
            GUILayout.Space(40);
            if(GUILayout.Button("Back", GUILayout.Width(200), GUILayout.Height(20))){
                conditionsMenu = false;
                mainMenu = true;
            }      
        }
    }
}

You are aware that your 3 boolean are inside the OnGUI method? Which mean every frame, they are reset to their default values?

I didn’t know that the frame is called every second even in the editor, but putting the variables anywhere else gives me an error.

Oh really?

What does that mean?

What error? Where did you put those variable?

It’s SOLVED. I just put the variables on the outside of the class. :stuck_out_tongue:

You mean inside the class, but outside the functions.

No, no, it’s outside the class as well. But now I’m faced with a different problem. I’m sort of new to extending the editor, and through hours of research I can’t find anything that’ll help me access a variable from an editor script to a regular old script:
OpenEditor.js

#pragma strict
@CustomEditor(Mission)
@CanEditMultipleObjects
var autoStart : boolean = false;
class OpenEditor extends Editor{  
    function OnInspectorGUI(){
        if(GUILayout.Button("Open Editor")){
            var ink : MyEditor = EditorWindow.GetWindow(MyEditor, true);
            ink.Show();
            //Debug.Log("Editor is Opened!");
        }
        autoStart = EditorGUILayout.Toggle("Auto Start", autoStart);
    }
}

The button and toggle shows up in the inspector of whatever object I place the Mission.js on, and the button works in edit mode, however I don’t know how to access the autoStart toggle from the editor script to the script for play mode.
Any additional help would be nice! :slight_smile:
Mission.js

#pragma strict
private var autoStart : boolean;
function OnTriggerEnter(other : Collider){
    if(other.gameObject.tag == "Player"){
        Debug.Log("The Mission has BEGUN!");
    }
}

the target property points to the object, so if you cast it to Mission type, you can then access it’s variables
var missionComponent = target as Mission;
missionComponent.autoStart…

I knew target had something to do with it. After a bit more research, I SOLVED it:
OpenEditor.js

var mission : Mission = target;
mission.autoStart = EditorGUILayout.Toggle("Auto Start", mission.autoStart);

Mission.js

var autoStart : boolean = false;
function Start(){
    if(autoStart){
        Debug.Log("The Mission has BEGUN!");
    }
}