Example #1
0
    public void StackActiveUi(UiId uiId)
    {
        _prevSections.RemoveAll(s => s.uiId == uiId);

        if (_prevSections.Count <= 0)
        {
            return;
        }

        StackSection uisection = _prevSections[0];

        int count = 0;

        _prevSections.ForEach(x =>
        {
            Debug.Log("stack" + (count++) + " next ui : " + x.uiId);
        });

        if (uisection != null)
        {
            uisection.param.ResetParam();
            ActiveUi(uisection.uiId, uisection.param, uisection.spawnType, false);
        }
    }
Example #2
0
    public UiCtrl ActiveUi(UiId uiId, UiParam param = null,
                           UISpawntype spawnType    = UISpawntype.EUIPage,
                           bool push = true, bool clearstack = false)
    {
        UiCtrl ui = GetUi(uiCtrlList, uiId);

        if (ui == null)
        {
            var prefab = ResourceManager.instance.CreateUI(spawnType, uiId.ToString());

            if (prefab == null)
            {
                Debug.Assert(prefab != null, " ui resource is null spawnTyp : " + spawnType + " uiId :" + uiId.ToString());
                return(null);
            }

            ui = prefab.GetComponent <UiCtrl>();
            string value = ui.GetType().ToString();
            ui.uiId.Set(value);
            ui.SetActive(false);
        }

        if (ui != null && ui.gameObject != null)
        {
            RectTransform rt = ui.GetComponent <RectTransform>();

            Transform parent = (spawnType == UISpawntype.EUIPage) ? m_tRootPage : (spawnType == UISpawntype.EUIAbove) ? m_tRootAbove : m_tRootPopup;

            rt.SetParent(parent);
            rt.Reset();

            if (param == null)
            {
                param = new UiParam();
            }

            if (ui._uiParamBase != null)
            {
                ui._uiParamBase.Clear();
            }

            if (ui.uiResult != null)
            {
                ui.uiResult.Clear();
            }

            ui.SetUiParam(param);

            ui._Activate();

            ui.SetActive(true);

            ui._Init();

            if (clearstack)
            {
                _prevSections.Clear();
            }

            if (push)
            {
                UiCtrl uisection = ui.GetComponent <UiCtrl>() as UiCtrl;

                if (uisection != null)
                {
                    StackSection s = new StackSection();
                    s.uiId.Set(uisection.uiId);
                    s.param     = param;
                    s.spawnType = spawnType;
                    _prevSections.Insert(0, s);
                }
            }

            bool bPopup = (UISpawntype.EUIPopup == spawnType);

            if (!bPopup)
            {
                _currUi = ui;
                uiCtrlList.Add(ui);
            }

            if (bPopup)
            {
                uiPopupList.Add(ui);
            }
        }

        return(ui);
    }