Esempio n. 1
0
        public override void Update()
        {
            // Debug.LogError ("ToastDataUpdate: " + this);
            if (dirty)
            {
                dirty = false;
                if (this.data != null)
                {
                    switch (this.data.state.v)
                    {
                    case ToastData.State.Normal:
                    {
                        // Find current toast message
                        ToastMessage currentMessage = null;
                        {
                            if (this.data.messages.vs.Count > 0)
                            {
                                currentMessage = this.data.messages.vs[0];
                            }
                        }
                        // Process
                        if (currentMessage != null)
                        {
                            currentMessage.time.v = currentMessage.time.v + Time.deltaTime;
                            if (currentMessage.time.v >= currentMessage.duration.v)
                            {
                                // remove message
                                this.data.messages.remove(currentMessage);
                                // move to waitNext
                                this.data.state.v = ToastData.State.WaitNext;
                            }
                        }
                    }
                    break;

                    case ToastData.State.WaitNext:
                    {
                        this.data.state.v = ToastData.State.Normal;
                    }
                    break;

                    default:
                        Debug.LogError("unknown state: " + this.data.state.v);
                        break;
                    }
                }
                else
                {
                    Debug.LogError("data null");
                }
            }
        }
Esempio n. 2
0
        public void addMessage(string message)
        {
            ToastMessage toastMessage = new ToastMessage();

            {
                toastMessage.uid = this.messages.makeId();
                // index
                {
                    toastMessage.toastIndex.v = this.maxIndex.v;
                    this.maxIndex.v           = this.maxIndex.v + 1;
                }
                // message
                toastMessage.message.v = message;
                // time
                toastMessage.time.v = 0;
                // duration
                toastMessage.duration.v = ToastMessage.DefaultDuration;
            }
            this.messages.add(toastMessage);
        }
Esempio 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");
         }
     }
 }
Esempio n. 4
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 disappear
                     {
                         if (this.data.toastMessage.v.data != toastMessageUIData.toastMessage.v.data)
                         {
                             Disappear disappear = new Disappear();
                             {
                                 disappear.uid            = toastMessageUIData.state.makeId();
                                 disappear.toastMessage.v = new ReferenceData <ToastMessage>(this.data.toastMessage.v.data);
                             }
                             toastMessageUIData.state.v = disappear;
                         }
                         else
                         {
                             Logger.Log("not different, don't need to change");
                         }
                     }
                 }
                 else
                 {
                     Logger.LogError("toastMessageUI null");
                 }
             }
             else
             {
                 Logger.LogError("toastMessageUIData null");
             }
         }
         else
         {
             Logger.LogError("data null");
         }
     }
 }