Hi,
I have this test editor script:
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(GUIStuff))]
public class GUIStuffEditor : Editor {
bool selection0=false, selection1=false;
int toolBarSelection=0;
public override void OnInspectorGUI()
{
string[] toolBarOptions = {"Selection 0", "Selection 1"};
toolBarSelection = GUILayout.Toolbar(toolBarSelection, toolBarOptions);
Debug.Log ("Going to change bool vars");
selection0 = (toolBarSelection == 0);
selection1 = (toolBarSelection == 1);
Debug.Log ("OnInspectorGUI: Selection 0: "+selection0+ " Selection 1:"+selection1);
}
public void OnSceneGUI()
{
Debug.Log ("OnSceneGUI: Selection 0: "+selection0+ " Selection 1:"+selection1);
}
[MenuItem ("GameObject/Create Other/GUI Stuff")]
static void createGUIStuffObject() {
GameObject newObj = new GameObject("GUI Stuff");
GUIStuff stuff = newObj.AddComponent<GUIStuff>();
}
}
GuiStuff is the simplest test class:
using UnityEngine;
using System.Collections;
public class GUIStuff : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
In the Mac editor (Unity 4.3.4) the scripts above work as expected, and the debug line prints the current toolbar selection correctly.
In the Windows editor (Unity 4.3.4) everything works the first time (when a GUIStuff object is created), but as soon as you save the scene and reopen it, the debug line in SceneGUI always prints Selection 0: true Selection 1; false, independently of what’s selected on the toolbar.
Any ideas on what’s going on?
Cheers,
Alex