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;
}
}
}
}
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! 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…