Esempio n. 1
0
    public UIWindowInfo FetchWinInfo(UIWindowEnum name)
    {
        UIWindowInfo result = null;

        winInfoDict.TryGetValue((int)name, out result);
        return(result);
    }
Esempio n. 2
0
    public void PrepareLoadUIWindow(UIWindowEnum name)
    {
        UIWindowInfo winInfo = winInfoDict[(int)name];
        var          win     = GetOrLoadUiWindow(winInfo);

        if (win != null && win.gameObject != null)
        {
            win.gameObject.SetActive(true);
        }
    }
Esempio n. 3
0
 private void Start()
 {
     {
         scale    = Screen.width / (400f / 1f);
         mainRect = new Rect(0, 0, Screen.width / scale, Screen.height / scale);
     }
     Windows    = new UIWindowInfo[3];
     Windows[0] = new UIWindowInfo(UIUtil.GetRect(new Vector2(400, 400), PositionAnchor.Center, mainRect.size));//main
     Windows[1] = new UIWindowInfo(UIUtil.GetRect(new Vector2(400, 400), PositionAnchor.Center, mainRect.size));
     Windows[2] = new UIWindowInfo(UIUtil.GetRect(new Vector2(400, 200), PositionAnchor.Center, mainRect.size));
 }
Esempio n. 4
0
        private void OnEnable()
        {
            GameController.Instance.Blinds.GoFadeIn();
            canvas.SetActive(true);

            scale    = Screen.width / (400f / 1f);
            mainRect = new Rect(0, 0, Screen.width / scale, Screen.height / scale);
            Global   = GameController.Instance;

            Windows    = new UIWindowInfo[2];
            Windows[0] = new UIWindowInfo(UIUtil.GetRect(new Vector2(400, 200), PositionAnchor.Center, mainRect.size));
        }
Esempio n. 5
0
    public UIWindowBase GetOrLoadUiWindow(UIWindowInfo winInfo)
    {
        UIWindowBase win;

        if (winLoadedDict.TryGetValue((int)winInfo.windowEnum, out win))
        {
            return(win);
        }

        GameObject obj = Resources.Load(winInfo.PrefabFullPath) as GameObject;

        if (obj = null)
        {
            Debug.LogError("加载win出错");
            return(null);
        }

        GameObject   ui       = obj;
        UIWindowBase uiWindow = ui.GetComponent <UIWindowBase>();

        if (uiWindow == null)
        {
            Debug.LogError("perfab doesn't have window Script");
            return(null);
        }

        winLoadedDict[(int)winInfo.windowEnum] = uiWindow;

        if (winInfo.windowType == UIWindowType.oNormal)
        {
            uiWindow.transform.SetParent(normalWindowRoot);
        }
        else
        {
            uiWindow.transform.SetParent(popupWindowRoot);
        }


        var cvs = ui.GetComponent <Canvas>();

        if (cvs != null && !cvs.overrideSorting)
        {
            cvs.overrideSorting = true;
            cvs.sortingOrder    = 3;
        }

        //描点处理
        //TODO..

        return(uiWindow);
    }
Esempio n. 6
0
    private void ShowUIWindowReal(UIWindowEnum name, bool ctrlEvent, GameObject mask, CtrlParams par = null)
    {
        bool isAlreadyLoad = winLoadedDict.ContainsKey((int)winInfoDict[(int)name].windowEnum);

        UIWindowBase uiWindow = GetOrLoadUiWindow(winInfoDict[(int)name]);
        UIWindowInfo winInfo  = winInfoDict[(int)name];

        if (!winOpenedSet.Contains((int)name))
        {
            winOpenedSet.Add((int)name);
        }
        else
        {
            Debug.LogWarning("window is opened twice");
        }

        TrySetWindowActive(name, !hideWinNames.Contains((int)name));
        TryClearLoadedWindowLRU(name);
        return;
    }
    private void InitController(UIWindowInfo info)
    {
        UIWindowEnum winName    = info.windowEnum;
        string       ctrlerName = info.ControllerName;

        Type type = Type.GetType(ctrlerName);

        if (type == null)
        {
            Debug.LogError(winName + "无法获取type ctrlerName" + ctrlerName);
            return;
        }

        UIBaseController controller = Activator.CreateInstance(type) as UIBaseController;

        if (controller == null)
        {
            Debug.LogError(winName + "无法生成controller");
            return;
        }

        winCtrlerDict.Add((int)winName, controller);
        controller.RegisterEvent();
    }
Esempio n. 8
0
    private static void RegisterWinInfoToDict(Dictionary <int, UIWindowInfo> dict, UIWindowEnum name, UIWindowType type, string path)
    {
        UIWindowInfo info = new UIWindowInfo(name, type, path);

        dict.Add((int)name, info);
    }