예제 #1
0
    public UIWindow GetWindow(EUIWindowKey windowKey)
    {
        int windowIndex = _activeWindows.FindIndex((UIWindow w) => { return(w.WindowKey == windowKey); });

        if (windowIndex != -1)
        {
            return(_activeWindows[windowIndex]);
        }

        GameObject windowResource = UIResourcesManager.Instance.GetResource <GameObject>(_windowResources[windowKey]);

        if (windowResource != null)
        {
            UIWindow windowInstance = (GameObject.Instantiate(windowResource) as GameObject).GetComponent <UIWindow>();
            windowInstance.transform.SetParent(Utils.UI.GetWindowsCanvas().transform, false);
            windowInstance.gameObject.SetActive(false);
            windowInstance.AddDisplayAction(EUIWindowDisplayAction.PreShow, OnWindowShow);
            windowInstance.AddDisplayAction(EUIWindowDisplayAction.PreHide, OnWindowHide);

            _activeWindows.Add(windowInstance);

            return(windowInstance);
        }

        return(null);
    }
예제 #2
0
    public UIWindow GetWindow(EUIWindowKey windowKey, Transform parentTransform)
    {
        GameObject windowResource = UIResourcesManager.Instance.GetResource <GameObject>(_windowResources[windowKey]);

        if (windowResource != null)
        {
            UIWindow windowInstance = (GameObject.Instantiate(windowResource) as GameObject).GetComponent <UIWindow>();
            windowInstance.transform.SetParent(parentTransform, false);
            windowInstance.gameObject.SetActive(false);

            windowInstance.AddDisplayAction(EUIWindowDisplayAction.PreShow, OnWindowShow);
            windowInstance.AddDisplayAction(EUIWindowDisplayAction.PreHide, OnWindowHide);

            return(windowInstance);
        }
        return(null);
    }