Example #1
0
    /// <summary>
    /// Open a new UI window
    /// </summary>
    /// <param name="name"> The name of the UI window to be opened </param>
    /// <param name="mode"> The mode to be used to open the UI window </param>
    /// <param name="args"> Extra arguments passed to UIWindow.OnOpen() </param>
    /// <returns></returns>
    public UIWindow Open(string name, UIMode mode = UIMode.Default, params object[] args)
    {
#if UNITY_EDITOR
        LogUtility.PrintLog("UI", IsInViewport(name) ? name + " is already in viewport" : "Open " + name);
#endif

        if (IsInViewport(name))
        {
            return(uiWindowsOpened[name]);
        }

        UIWindow uiWindow = Instantiate(ResourceUtility.GetUIPrefab <UIWindow>(name), transform, false);

        uiWindow.transform.SetSiblingIndex(0);

        uiWindowsOpened.Add(name, uiWindow);

        uiWindow.OnOpen(args);

        if (mode != UIMode.Permenent)
        {
            uiWindowStack.Push(name);
        }

        return(uiWindow);
    }