Ejemplo n.º 1
0
        protected async Task <UIInstance> Open <T>(string path, TParam prm, UIInstance parent = null) where T : UControl
        {
            UIControlLog.Debug("[ilib-ui] Open:{0}, prm:{1}, parent:{2}", path, prm, parent);
            StartProcess();
            try
            {
                await OnBeginOpen();

                var prefab = await Load <T>(path, prm);

                var obj = Instantiate(prefab, transform);
                var ui  = obj.GetComponent <T>();

                ui.SetController(this);

                var behind = parent?.Control?.OnBehind(prm);

                await ui.OnCreated(prm);

                OnOpen(ui);

                if (behind != null && IsWaitBehindBeforeOnFront <T>(path, prm))
                {
                    var hide = await behind;
                    behind = null;
                    if (hide && parent != null && parent.Control != null)
                    {
                        parent.Object.SetActive(false);
                    }
                }

                await ui.OnFront(open : true);

                if (behind != null)
                {
                    var hide = await behind;
                    if (hide && parent != null && parent.Control != null)
                    {
                        parent.Object.SetActive(false);
                    }
                }

                await OnEndOpen();

                var ret = new UIInstance();
                ret.Control = ui;
                ret.Object  = obj;
                ret.Parent  = parent;
                return(ret);
            }
            finally
            {
                UIControlLog.Trace("[ilib-ui] Complete Open:{0}", path);
                EndProcess();
            }
        }
Ejemplo n.º 2
0
        protected async Task <UIInstance> Change <T>(string path, TParam prm, UIInstance parent, UIInstance[] releases) where T : UControl
        {
            UIControlLog.Debug("[ilib-ui] Change:{0}, prm:{1}, parent:{2}", path, prm, parent);

            StartProcess();
            try
            {
                await OnBeginChange();

                var loading = Load <T>(path, prm);

                var close = CloseControls(releases);

                var prefab = await loading;

                if (IsWaitCloseBeforeOnOpen <T>(path, prm))
                {
                    await close;
                }

                var obj = Instantiate(prefab, transform);
                var ui  = obj.GetComponent <T>();

                ui.SetController(this);

                await ui.OnCreated(prm);

                OnOpen(ui);

                await ui.OnFront(open : true);

                if (!close.IsCompleted)
                {
                    await close;
                }

                await OnEndChange();

                var ret = new UIInstance();
                ret.Control = ui;
                ret.Object  = obj;
                ret.Parent  = parent;
                return(ret);
            }
            finally
            {
                UIControlLog.Trace("[ilib-ui] Complete Change:{0}", path);
                EndProcess();
            }
        }
Ejemplo n.º 3
0
        protected async Task Close(UIInstance[] releases, UIInstance front = null)
        {
            UIControlLog.Debug("[ilib-ui] Close, next front:{0}", front);
            StartProcess();
            try
            {
                await OnBeginClose();

                var close = CloseControls(releases);

                if (front != null)
                {
                    if (!front.Object.activeSelf)
                    {
                        front.Object.SetActive(true);
                    }
                    if (IsWaitCloseBeforeOnFront(front.Control as UControl))
                    {
                        await close;
                    }
                    await front.Control.OnFront(open : false);
                }

                if (!close.IsCompleted)
                {
                    await close;
                }

                await OnEndClose();
            }
            finally
            {
                UIControlLog.Trace("[ilib-ui] Complete Close");
                EndProcess();
            }
        }
Ejemplo n.º 4
0
 public void SetInstance(UIInstance instance)
 {
     Instance = instance;
     m_Task.SetResult(this);
 }