Hey everyone,
Coming from a Flash/AS3 background, I tend to think of UI from the traditional event-driven standpoint… So my question might be unfounded based on Unity’s GUI approach. I’m having trouble with GUI events cascading to UI that the currently-focused UI is overlaying. In this example, just drag either window over the other and try clicking the button. you notice that as long as the mouse pointer is over a button, regardless of it being in the currently focused window, it will register a click.
using UnityEngine;
using System.Collections;
public class GameUI : MonoBehaviour {
private Rect windowRect;
private Rect windowRect2;
private Vector2 windowScrollPosition;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI()
{
windowRect = GUILayout.Window(0, windowRect, onWindow, "Window One",GUILayout.Height(100),GUILayout.Width(200));
windowRect2 = GUILayout.Window(1, windowRect2, onWindow2, "Window Two");
}
private void onWindow(int i)
{
windowScrollPosition = GUILayout.BeginScrollView(windowScrollPosition);
GUILayout.Button("Meowing Cats");
GUILayout.Button("Meowing Cats");
GUILayout.Button("Meowing Cats");
GUILayout.Button("Meowing Cats");
GUILayout.Button("Meowing Cats");
GUILayout.Button("Meowing Cats");
GUILayout.Button("Meowing Cats");
GUILayout.EndScrollView();
GUI.DragWindow();
}
private void onWindow2(int i)
{
GUILayout.Button("Das Button");
GUI.DragWindow();
}
}
Is this a feature or a bug? If a feature, what can I use to stop event cascading? If a bug, what’re some of the work-arounds?
Thanks everyone, and apologies if this has been asked before somewhere.
-Jay