コード例 #1
0
    private static IEnumerator ExcutePopPanelCloseTask()
    {
        yield return(CurrentPopPanel.Close());

        CurrentPopPanel = null;
        _popCloseCor    = null;
    }
コード例 #2
0
    private static IEnumerator ExcuteBasePanelShowTask()
    {
        while (BasePanelTasks.Count > 0)
        {
            int   panelIndex = BasePanelTasks.Dequeue();
            int[] args       = BasePanelTaskParams.Dequeue();
            if (allPanelDic.TryGetValue(panelIndex, out IUIBase tempUI))
            {
                if (tempUI is null)
                {
                    Debug.LogError("保存的接口为空,面板类型ID:" + panelIndex);
                    allPanelDic.Remove(panelIndex);
                    continue;
                }
                if (CurrentBasePanel is object)
                {
                    if (tempUI == CurrentBasePanel)
                    {
                        Debug.LogError("已经显示当前面板,面板类型ID:" + panelIndex);
                        continue;
                    }
                    yield return(CurrentBasePanel.Close());
                }
                CurrentBasePanel = tempUI;
                MenuPanel.OnBasePanelShow(panelIndex);
                yield return(CurrentBasePanel.Show(args));
            }
            else
            {
                if (loadedpanelPrefabDic.TryGetValue(panelIndex, out GameObject tempPrefab))
                {
                    if (tempPrefab is null)
                    {
                        Debug.LogError("加载预制体的资源为空,面板类型ID:" + panelIndex);
                        loadedpanelPrefabDic.Remove(panelIndex);
                        continue;
                    }
                    GameObject tempUIGo = GameObject.Instantiate(tempPrefab, BaseRoot);
                    tempUI = tempUIGo.GetComponent <IUIBase>();
                    allPanelDic.Add(panelIndex, tempUI);
                    allPanelGoDic.Add(panelIndex, tempUIGo);
                    if (CurrentBasePanel is object)
                    {
                        if (tempUI == CurrentBasePanel)
                        {
                            Debug.LogWarning("已经显示当前面板,面板类型ID:" + panelIndex);
                            continue;
                        }
                        yield return(CurrentBasePanel.Close());
                    }
                    CurrentBasePanel = tempUI;
                    MenuPanel.OnBasePanelShow(panelIndex);
                    yield return(CurrentBasePanel.Show(args));
                }
                else
                {
                    if (panelPathDic.TryGetValue(panelIndex, out string tempUIPath))
                    {
                        tempPrefab = Resources.Load <GameObject>(tempUIPath);
                        if (tempPrefab is null)
                        {
                            Debug.LogError("加载预制体的资源为空,面板类型ID:" + panelIndex);
                            loadedpanelPrefabDic.Remove(panelIndex);
                            continue;
                        }
                        loadedpanelPrefabDic.Add(panelIndex, tempPrefab);

                        GameObject tempUIGo = GameObject.Instantiate(tempPrefab, BaseRoot);
                        tempUI = tempUIGo.GetComponent <IUIBase>();
                        allPanelDic.Add(panelIndex, tempUI);
                        allPanelGoDic.Add(panelIndex, tempUIGo);
                        if (CurrentBasePanel is object)
                        {
                            if (tempUI == CurrentBasePanel)
                            {
                                Debug.LogWarning("已经显示当前面板,面板类型ID:" + panelIndex);
                                continue;
                            }
                            yield return(CurrentBasePanel.Close());
                        }
                        CurrentBasePanel = tempUI;
                        MenuPanel.OnBasePanelShow(panelIndex);
                        yield return(CurrentBasePanel.Show(args));
                    }
                    else
                    {
                        Debug.LogError("没有配置面板预制体资源路径,面板类型ID:" + panelIndex);
                    }
                }
            }
        }
        _baseAnimationCor = null;
    }