Example #1
0
    public void openUI(UIEnum e, BaseData data)
    {
        BaseUI baseUI = null;

        if (!uis.TryGetValue(e, out baseUI))
        {
            string path = UIPath.getUIPath(e);
            ResMgr.Instance.load(path, (obj) =>
            {
                GameObject go = obj as GameObject;
                if (go != null)
                {
                    baseUI = go.GetComponent <BaseUI>();
                    if (baseUI == null)
                    {
                        Type t = UIPath.getType(e);
                        baseUI = go.AddComponent(t) as BaseUI;
                    }
                    baseUI.setData(data);
                    uis.Add(e, baseUI);
                }
            });
        }
        else
        {
            baseUI.setData(data);
            baseUI.setActive(true);
        }
    }
Example #2
0
        /// <summary>
        /// Create Url Path
        /// </summary>
        /// <param name="main"></param>
        /// <param name="text"></param>
        /// <param name="action"></param>
        public void InsertItemToPath(byte main, string text, string action)
        {
            UIPath item = new UIPath();

            item.Action = action;

            if (main == (byte)eMain.Cv)
            {
                item.Controller = "CV";
            }
            else if (main == (byte)eMain.Admin)
            {
                item.Controller = "Admin";
            }

            item.Text   = text;
            item.Action = action;

            if (Items.Count != 0)
            {
                UIPath lastItem = Items.Last();
                item.Sequence = lastItem.Sequence + 1;
            }
            else
            {
                item.Sequence = 0;
            }
            this.Items.Add(item);
        }
    private void Start()
    {
        //thisRotation = this.transform.rotation.eulerAngles.z;

        panelPopUp        = gameObject.GetComponentInParent <rotationPanelPopUp>();
        buttonUIScript    = panelPopUp.buttonUI.GetComponent <UIPath>();
        referenceButtonUI = panelPopUp.buttonUI;
    }
Example #4
0
        public async Task <T> LoadUIAsync <T>() where T : class
        {
            string     path = UIPath.GetPath <T>();
            GameObject go   = await Addressables.LoadAssetAsync <GameObject>(path).Task;

            go = MonoBehaviour.Instantiate(go);
            UIConsole.InsertUI(go.transform);
            T ui = go.GetComponent <T>();

            UIs.Add(typeof(T), go);
            return(ui);
        }
Example #5
0
    public void showUI(EUiId id)
    {
        //1:加载当前UI
        if (dicShowUI.ContainsKey(id))//当前UI已经在显示列表中了,就直接返回
        {
            return;
        }
        UIBasePanel ui = getUI(id);               //通过ID获取需要显示的UI,从dicAllUI容器中获取,得到的是隐藏的UIPanel

        if (ui == null)                           //如果在dicAllUI容器中没有此UI,就从资源中读取ui预制体
        {
            string path = UIPath.getUiIdPath(id); //通过ID,获取对应的路径
            if (!string.IsNullOrEmpty(path))
            {
                GameObject prefab = Resources.Load <GameObject>(path);//加载资源
                //获取UI原始数据
                Vector2 offMin    = prefab.GetComponent <RectTransform>().offsetMin;
                Vector2 offMax    = prefab.GetComponent <RectTransform>().offsetMax;
                Vector2 anchorMin = prefab.GetComponent <RectTransform>().anchorMin;
                Vector2 anchorMax = prefab.GetComponent <RectTransform>().anchorMax;
                if (prefab != null)                                           //资源加载成功
                {
                    GameObject goWillShowUI = GameObject.Instantiate(prefab); //克隆游戏对象到层次面板上
                    //goWillShowUI.SetActive(true);
                    ui = goWillShowUI.GetComponent <UIBasePanel>();           //获取此对象上的UI
                    if (ui != null)
                    {
                        //Transform root = getUIRoot(ui);//获取UI所对应的根节点
                        //放入根节点下面
                        UtilUI.addChildToParent(transUIRoot, goWillShowUI.transform);//放入根节点下面
                        //数据的恢复
                        goWillShowUI.GetComponent <RectTransform>().offsetMin = offMin;
                        goWillShowUI.GetComponent <RectTransform>().offsetMax = offMax;
                        goWillShowUI.GetComponent <RectTransform>().anchorMin = anchorMin;
                        goWillShowUI.GetComponent <RectTransform>().anchorMax = anchorMax;
                        prefab = null;//清空预制体对象
                    }
                }
                else
                {
                    Debug.LogError("资源" + path + "不存在");
                }
            }
        }
        //2:更新显示其它的UI
        UpdateOtherUIState(ui);

        //3:显示当前UI
        dicAllUI[id]  = ui;
        dicShowUI[id] = ui;
        ui.show();
    }
Example #6
0
        /// <summary>
        /// Update the UI path.
        /// </summary>
        /// <param name="currentUI"></param>
        public void AddUIPath(UIBase currentUI)
        {
            // First check if this UI is a root UI
            if (currentUI.Properties.IsRootUI)
            {
                // If this UIs display mode is HideOther
                if (currentUI.Properties.GetDisplayMode == DisplayUIMode.HideOthers)
                {
                    // Create a new node of path.
                    UIPath newNode = new UIPath();
                    newNode.CurrentDisplayingUI = currentUI;
                    // Check all the UIs in scene and find out which are displaying.
                    foreach (var item in m_NormalUIs)
                    {
                        // Unless the UI's display mode is NeverHide, all of them have to hide.
                        if (item.Value.Properties.GetDisplayMode != DisplayUIMode.NeverHide &&
                            item.Value != currentUI && item.Value.IsDisplaying)
                        {
                            // Hide the UI.
                            item.Value.HideUI();
                            // Remenber which UI was hided.
                            newNode.PreviousUIs.Add(item.Value);
                        }
                    }

                    foreach (var item in m_UIWontDestoryThroughSceneChange)
                    {
                        // Unless the UI's display mode is NeverHide, all of them have to hide.
                        if (item.Value.Properties.GetDisplayMode != DisplayUIMode.NeverHide &&
                            item.Value != currentUI && item.Value.IsDisplaying)
                        {
                            // Hide the UI.
                            item.Value.HideUI();
                            // Remenber which UI was hided.
                            newNode.PreviousUIs.Add(item.Value);
                        }
                    }
                    // If nothing changes
                    m_UIPathTracker.Push(newNode);
#if UNITY_EDITOR
                    Debug.Log("New Path node count: " + m_UIPathTracker.Count + " current UI: " + currentUI);
#endif
                }
            }
        }
Example #7
0
        private void InitTechGroup()
        {
            Func <TechnologyGroup.GroupType, GameObject> getGroupObject = (o) =>
            {
                switch (o)
                {
                case TechnologyGroup.GroupType.Panel_3_1_1:
                    return(ObjectManager.Instance.InstantiateObject(UIPath.TechGroupPrefabPath(o)));

                default:
                    return(null);
                }
            };

            var groupList = TechnologyModule.Instance.groupConfig.InitGroupIndexList;

            for (int i = 0; i < groupList.Count; i++)
            {
                var config = TechnologyModule.Instance.GetTechGroupConfig(groupList[i]);
                if (config != null)
                {
                    var             obj   = getGroupObject(TechnologyModule.Instance.GetTechGroupType(config.groupIndex));
                    TechnologyGroup group = obj.transform.SafeGetComponent <TechnologyGroup>();
                    if (group != null)
                    {
                        if (!group.InitGroup(config.groupIndex))
                        {
                            break;
                        }
                        obj.transform.SetParent(Transform.FindTransfrom("Content/Scroll View/Viewport/Content"), false);
                        Vector3 configPos = new Vector3(config.posX, config.posY, 0);
                        var     rect      = obj.transform.SafeGetComponent <RectTransform>();
                        rect.anchoredPosition = configPos;

                        if (!_groupList.Contains(group))
                        {
                            _groupList.Add(group);
                        }
                    }
                }
            }
        }
Example #8
0
        private GameObject CreateGameObject(UIPath path)
        {
            GameObject preObj = Resources.Load(LocalPath + path.Path
                        , typeof(GameObject)) as GameObject;

            GameObject obj = GameObject.Instantiate(preObj) as GameObject;

            GameObject root=GameObject.Find(LocalRoot);
            obj.transform.parent = root.transform;
            obj.transform.localPosition = path.Position;
            obj.transform.localRotation = Quaternion.identity;
            obj.transform.localScale = Vector3.one;
            obj.name = path.Name;
#if NGUI_3
            obj.GetComponent<UIPanel>().depth = path.Depth;
#else
            Vector3 zbuffer=obj.transform.localPosition;
            zbuffer.z = path.Depth;
            obj.transform.localPosition = zbuffer;
#endif
            return obj;
        }