Exemplo n.º 1
0
        protected IEnumerator LoadPanelAsync(UIPanelSettings settings)
        {
            Log("LoadPanelAsync " + settings.PanelType);
            m_loadingPanels.Add(settings.PanelType);
            var assetKey  = GetPathByAttribute(settings.PanelType);
            var container = m_layers[settings.Layer];

            Assert.IsNotNull(container, $"Can't get layer {settings.Layer}");

            UIPanel panel = null;

            m_content.InstantiateComponentAsync <UIPanel>(assetKey, (result) =>
            {
                Assert.IsTrue(result.status == RequestStatus.SUCCESS, $"panel {GetType()} load failure!!!");
                panel = result.result as UIPanel;
                Assert.IsTrue(panel != null, $"panel {GetType()} load failure!!!");
            }, container);
            yield return(new WaitUntil(() => panel != null));

            Assert.IsNotNull(panel, $"LoadPanelAsync failed for {settings.PanelType}: key={assetKey}");

            InstantiatePanel(panel, settings);
            m_loadingPanels.Remove(settings.PanelType);
            Log("End LoadPanelAsync " + settings.PanelType);
        }
Exemplo n.º 2
0
        protected void InstantiatePanel(UIPanel panel, UIPanelSettings settings)
        {
            Log("InstantiatePanel " + settings.PanelType);
            m_panels.Add(settings.PanelType, panel);
            panel.ChangePanelEvent      += OnChangePanelHandler;
            panel.HidePanelEvent        += OnHidePanelHandler;
            panel.ShowPanelEvent        += OnShowPanelHandler;
            panel.UpdatePanelEvent      += OnUpdatePanelHandler;
            panel.ShowAsSubpanelEvent   += OnShowAsSubpanelHandler;
            panel.PanelDataChangedEvent += OnPanelDataChangedHandler;

            panel.Initialize(UiDataProvider, settings);
            panel.gameObject.SetActive(false);
        }
Exemplo n.º 3
0
 private void SetSubPanel(UIPanel uiPanel, UIPanel subPanel)
 {
     subPanel.transform.SetParent(uiPanel.SubpanelHolder);
     subPanel.transform.localScale = Vector3.one;
 }