Ejemplo n.º 1
0
        public T CreateWidget <T>(string path, bool dontDestroyOnLoad = false) where T : WidgetBase
        {
            WidgetBase widget = FindWidget(path);

            if (widget != null)
            {
                InitWidget(path, widget, null);

                if (widget.IsPopupType)
                {
                    RemoveWidget(widget);
                    AddWidget(path, widget, dontDestroyOnLoad);
                }

                return(widget as T);
            }
            else
            {
                return(LoadWiget <T>(path, dontDestroyOnLoad));
            }
        }
Ejemplo n.º 2
0
        public void AddFlow(WidgetBase currentWidget, float activeTime, IUIDataParams data)
        {
            if (currentWidget.IsFlow == false)
            {
                return;
            }

            WidgetBase prevWidget = null;

            if (string.IsNullOrEmpty(m_currentUIName) == false)
            {
                prevWidget = FindWidget(m_currentUIName);
            }

            if (prevWidget != null)
            {
                m_commandManager.CurrentCommand = new UIFlowCommand(prevWidget, currentWidget, activeTime, data);
                m_commandManager.Execute();
            }
            m_currentUIName = currentWidget.WidgetName;
        }
Ejemplo n.º 3
0
        //public void CreateWidgetAsync<T>(string path, bool dontDestroyOnLoad, System.Action<T> action) where T : WidgetBase
        //{
        //    WidgetBase widget = FindWidget(typeof(T).ToString());

        //    if (widget != null)
        //    {
        //        InitWidget(widget, null);

        //        if (widget.IsPopupType)
        //        {
        //            RemoveWidget(widget);
        //            AddWidget(widget, dontDestroyOnLoad);
        //        }

        //        if (action != null)
        //        {
        //            action(widget as T);
        //        }
        //    }
        //    else
        //    {
        //        m_uiManager.Setting.StartCoroutine(LoadWigetAsync<T>(path, dontDestroyOnLoad, action));
        //    }
        //}

        public IEnumerator OnCreateWidgetAsync <T>(string path, System.Action <T> action, bool dontDestroyOnLoad)
            where T : WidgetBase
        {
            WidgetBase widget = FindWidget(path);

            if (widget != null)
            {
                InitWidget(path, widget, null);

                if (widget.IsPopupType)
                {
                    RemoveWidget(widget);
                    AddWidget(path, widget, dontDestroyOnLoad);
                }

                action(widget as T);
            }
            else
            {
                yield return(LoadWigetAsync <T>(path, dontDestroyOnLoad, action));
            }
        }
Ejemplo n.º 4
0
        protected void AddWidget(string path, WidgetBase widget, bool dontDestroyOnLoad)
        {
            if (m_widgetRepository == null || m_dontDestroy_widgetRepository == null)
            {
                return;
            }

            string widgetName = path;

            if (FindWidget(widgetName) != null)
            {
                return;
            }

            if (dontDestroyOnLoad)
            {
                m_dontDestroy_widgetRepository.Insert(widget);
            }
            else
            {
                m_widgetRepository.Insert(widget);
            }
        }
Ejemplo n.º 5
0
        protected void InitWidget(string path, WidgetBase widget, System.Action <WidgetBase> action)
        {
            if (widget == null)
            {
                return;
            }

            if (widget.IsPopupType == true)
            {
                widget.transform.SetParent(m_dynamicPanel != null ? m_dynamicPanel.transform : m_root.transform, true);
            }
            else
            {
                widget.transform.SetParent(m_staticPanel != null ? m_staticPanel.transform : m_root.transform, true);
            }

            if (Global.SceneMgr != null && Global.SceneMgr.CurrentScene != null)
            {
                widget.SetCamera(Global.SceneMgr.CurrentScene.UICamera, ++Global.SceneMgr.CurrentScene.WidgetLayer);
            }
            else
            {
                widget.SetCamera(null, 100);
            }

            widget.transform.localPosition = Vector3.zero;
            widget.transform.localRotation = Quaternion.identity;

            widget.InitializeWidget(path);

            //m_currentWidget = widget;

            if (action != null)
            {
                action(widget);
            }
        }