Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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)
                 {
                     // UI
                     {
                         ToastMessageUI.ShowRect.set((RectTransform)toastMessageUI.transform);
                         // tvMessage
                         {
                             if (toastMessageUI.tvMessage != null)
                             {
                                 ToastMessage toastMessage = this.data.toastMessage.v.data;
                                 if (toastMessage != null)
                                 {
                                     toastMessageUI.tvMessage.text = toastMessage.message.v;
                                 }
                                 else
                                 {
                                     Logger.LogError("toastMessage null");
                                 }
                             }
                             else
                             {
                                 Logger.LogError("tvMessage null");
                             }
                         }
                     }
                     // change to hide
                     {
                         Hide hide = new Hide();
                         {
                             hide.uid = toastMessageUIData.state.makeId();
                         }
                         toastMessageUIData.state.v = hide;
                     }
                 }
                 else
                 {
                     Logger.LogError("toastMessageUI null");
                 }
             }
             else
             {
                 Logger.LogError("toastMessageUIData null");
             }
         }
         else
         {
             Logger.LogError("data null");
         }
     }
 }