Exemplo n.º 1
0
        public override void onAddCallBack <T>(T data)
        {
            if (data is UIData)
            {
                Debug.Log("Toast position: " + this.transform.localPosition);
                UIData uiData = data as UIData;
                // Child
                {
                    uiData.state.allAddCallBack(this);
                }
                dirty = true;
                return;
            }
            // Child
            if (data is UIData.State)
            {
                UIData.State state = data as UIData.State;
                // Update
                {
                    switch (state.getType())
                    {
                    case UIData.State.Type.Hide:
                    {
                        Hide hide = state as Hide;
                        UpdateUtils.makeUpdate <HideUpdate, Hide>(hide, this.transform);
                    }
                    break;

                    case UIData.State.Type.Appear:
                    {
                        Appear appear = state as Appear;
                        UpdateUtils.makeUpdate <AppearUpdate, Appear>(appear, this.transform);
                    }
                    break;

                    case UIData.State.Type.Show:
                    {
                        Show show = state as Show;
                        UpdateUtils.makeUpdate <ShowUpdate, Show>(show, this.transform);
                    }
                    break;

                    case UIData.State.Type.Disappear:
                    {
                        Disappear disappear = state as Disappear;
                        UpdateUtils.makeUpdate <DisappearUpdate, Disappear>(disappear, this.transform);
                    }
                    break;

                    default:
                        Logger.LogError("unknown type: " + state.getType());
                        break;
                    }
                }
                dirty = true;
                return;
            }
            Debug.LogError("Don't process: " + data + "; " + this);
        }
Exemplo n.º 2
0
        public override void onRemoveCallBack <T>(T data, bool isHide)
        {
            if (data is UIData)
            {
                UIData uiData = data as UIData;
                // Child
                {
                    uiData.state.allRemoveCallBack(this);
                }
                this.setDataNull(uiData);
                return;
            }
            // Child
            if (data is UIData.State)
            {
                UIData.State state = data as UIData.State;
                // Update
                {
                    switch (state.getType())
                    {
                    case UIData.State.Type.Hide:
                    {
                        Hide hide = state as Hide;
                        hide.removeCallBackAndDestroy(typeof(HideUpdate));
                    }
                    break;

                    case UIData.State.Type.Appear:
                    {
                        Appear appear = state as Appear;
                        appear.removeCallBackAndDestroy(typeof(AppearUpdate));
                    }
                    break;

                    case UIData.State.Type.Show:
                    {
                        Show show = state as Show;
                        show.removeCallBackAndDestroy(typeof(ShowUpdate));
                    }
                    break;

                    case UIData.State.Type.Disappear:
                    {
                        Disappear disappear = state as Disappear;
                        disappear.removeCallBackAndDestroy(typeof(DisappearUpdate));
                    }
                    break;

                    default:
                        Logger.LogError("unknown type: " + state.getType());
                        break;
                    }
                }
                return;
            }
            Debug.LogError("Don't process: " + data + "; " + this);
        }
Exemplo n.º 3
0
 public override void Update()
 {
     base.Update();
     if (dirty)
     {
         dirty = false;
         if (this.data != null)
         {
             ToastMessageUI.UIData toastMessageUIData = this.data.findDataInParent <ToastMessageUI.UIData>();
             if (toastMessageUIData != null)
             {
                 ToastMessageUI toastMessageUI = toastMessageUIData.findCallBack <ToastMessageUI>();
                 if (toastMessageUI != null)
                 {
                     // parent position to hide
                     {
                         // toastMessageUI.transform.localPosition = ToastMessageUI.HidePos;
                         ToastMessageUI.HideRect.set((RectTransform)toastMessageUI.transform);
                     }
                     // check current toast message
                     {
                         if (this.data.toastMessage.v.data != null)
                         {
                             // update UI
                             {
                                 if (toastMessageUI.tvMessage != null)
                                 {
                                     toastMessageUI.tvMessage.text = this.data.toastMessage.v.data.message.v;
                                 }
                                 else
                                 {
                                     Logger.LogError("toastMessageUI null");
                                 }
                             }
                             // change to appear
                             {
                                 Appear appear = new Appear();
                                 {
                                     appear.uid            = toastMessageUIData.state.makeId();
                                     appear.toastMessage.v = new ReferenceData <ToastMessage>(this.data.toastMessage.v.data);
                                 }
                                 toastMessageUIData.state.v = appear;
                             }
                         }
                         else
                         {
                             if (toastMessageUIData.toastMessage.v.data != null)
                             {
                                 // update UI
                                 {
                                     if (toastMessageUI.tvMessage != null)
                                     {
                                         toastMessageUI.tvMessage.text = toastMessageUIData.toastMessage.v.data.message.v;
                                     }
                                     else
                                     {
                                         Logger.LogError("toastMessageUI null");
                                     }
                                 }
                                 this.data.toastMessage.v = new ReferenceData <ToastMessage>(toastMessageUIData.toastMessage.v.data);
                             }
                         }
                     }
                     // wrap content
                     {
                         if (toastMessageUI.toastMessageContainer != null)
                         {
                             toastMessageUI.toastMessageContainer.enabled = false;
                             toastMessageUI.toastMessageContainer.enabled = true;
                         }
                         else
                         {
                             Logger.LogError("toastMessageContainer null");
                         }
                     }
                 }
                 else
                 {
                     Logger.LogError("toastMessageUI null");
                 }
             }
             else
             {
                 Logger.LogError("toastMessageUIData null");
             }
         }
         else
         {
             Logger.LogError("data null");
         }
     }
 }