Example #1
0
    /// <summary>
    /// Close a previously opened UI window
    /// </summary>
    /// <param name="name"> The name of the UI window to be closed </param>
    public void Close(string name)
    {
#if UNITY_EDITOR
        Debug.Log(LogUtility.MakeLogStringFormat("UI", IsInViewport(name) ? "Close " + name : name + " is not in viewport"));
#endif

        if (IsInViewport(name))
        {
            GUIWindow ui = uiWindowsOpened[name];

            ui.OnClose();

            Stack <string> s = new Stack <string>();

            while (uiWindowStack.Peek().CompareTo(name) != 0)
            {
                s.Push(uiWindowStack.Pop());
            }

            uiWindowStack.Pop();

            while (s.Count > 0)
            {
                uiWindowStack.Push(s.Pop());
            }

            Destroy(ui.gameObject);

            uiWindowsOpened.Remove(name);
        }
    }
    /// <summary>
    /// Close a previously opened UI window
    /// </summary>
    /// <param name="name"> The name of the UI window to be closed </param>
    public void Close(string name)
    {
#if UNITY_EDITOR
        Debug.Log(LogUtility.MakeLogStringFormat("UI", IsInViewport(name) ? "Close " + name : name + " is not in viewport"));
#endif

        if (IsInViewport(name))
        {
            GUIWindow ui = uiWindowsOpened[name];

            ui.OnClose();

            Stack <string> s = new Stack <string>();

            while (uiWindowStack.Peek().CompareTo(name) != 0)
            {
                s.Push(uiWindowStack.Pop());
            }

            uiWindowStack.Pop();

            while (s.Count > 0)
            {
                uiWindowStack.Push(s.Pop());
            }

            if (!ui.gameObject.name.Contains("MainMenu"))
            {
                FMOD.Studio.EventInstance cancelSound = FMODUnity.RuntimeManager.CreateInstance("event:/Interface/Cancel");
                cancelSound.start();
            }
            Destroy(ui.gameObject);

            uiWindowsOpened.Remove(name);
        }
    }