Example #1
0
        /// <summary>
        /// Current showing view
        /// </summary>
        /// <param name="type"></param>
        /// <param name="AttachedView"></param>
        public GameObject OpenPopUI(E_PopupType type, E_UIType attachedView = E_UIType.PopupUI, bool isSingleton = false)
        {
            int popIndex = GetPopupIndex(type);

            if (isSingleton && popIndex != -1)
            {
                return(popCp.popups[popIndex].uis[0]);
            }

            Transform _parent = UISystem.Instance.GetCanvas(attachedView).transform;

            UISystem.Instance.PopToFront(E_UIType.PopupUI);

            var _pop = UISystemUtil.CreateUIFromPrefab(poolSystem, (int)type, popCp.POP_PATH + type.ToString(), _parent);

            _pop.transform.SetSiblingIndex(0);

            // Update container
            if (popIndex == -1)
            {
                popCp.popups.Add(new PopupDatas(type, new GameObject[] { _pop }));
            }
            else
            {
                popCp.popups[popIndex].uis.Add(_pop);
            }

            popuiShowSystem.ShowView(_pop);

            return(_pop);
        }
Example #2
0
        GameObject CreateUI(E_UIType type, bool isSingleton = false)
        {
            int index = GetViewTypeIndex(type);

            if ((isSingleton && index == -1) || !isSingleton)
            {
                GameObject canvasObj = GetCanvas(type);

                // Instantiate
                // var prefab = poolSystem.Get((int)type);
                // if (prefab == null)
                // {
                //     prefab = Resources.Load<GameObject>(uiCp.UI_PATH + type.ToString());
                //     poolSystem.Push((int)type, prefab);
                // }
                // var ui = GameObject.Instantiate(prefab, canvasObj.transform);
                var ui = UISystemUtil.CreateUIFromPrefab(poolSystem,
                                                         (int)type,
                                                         uiCp.UI_PATH + type.ToString(),
                                                         canvasObj.transform);

                // Add to container
                if (index == -1)
                {
                    uiCp.views.Add(new Views(type, new GameObject[] { ui }));
                }
                else
                {
                    uiCp.views[index].uis.Add(ui);
                }

                index = uiCp.views.Count - 1;
            }

            return(GetUI(index));
        }