Ejemplo n.º 1
0
        /// <summary>
        /// Create new Toastr from template and enqueue.
        /// </summary>
        /// <param name="toastrToInstantiate"></param>
        public void CreateNewToastr(ToastrTemplate toastrToInstantiate)
        {
            GameObject toastrGameObject = Instantiate(toastrDesignPrefab);

            toastrGameObject.transform.SetParent(transform, false);
            toastrGameObject.transform.localPosition -= toastrQueue.Count * OFFSET * Vector3.up;

            toastrGameObject.name = toastrToInstantiate.toastrMessage;

            Toastr newToastr = toastrGameObject.GetComponent <Toastr>();

            newToastr.Init(toastrToInstantiate.toastrMessage, toastrToInstantiate.toastrColor, toastrToInstantiate.toastrFontSize);

            toastrQueue.Enqueue(newToastr);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Manage toastr timer.
        /// </summary>
        protected override void UpdateInClass()
        {
            // Check if hud is active to manage timer correctly.
            if (AdditiveSceneManager.CurrentSceneContainsHud())
            {
                if (IsToastrTemplateInQueue() && view != null)
                {
                    ToastrTemplate toastrToInstantiate = toastrToInstantiateQueue.Dequeue();
                    toastrActiveQueue.Enqueue(toastrToInstantiate);
                    ((ToastrView)view).CreateNewToastr(toastrToInstantiate);

                    if (toastrActiveQueue.Count == 1)
                    {
                        timer.SetTimer(toastrActiveQueue.Peek().toastrDuration, DestroyToastr);
                    }
                }

                if (toastrActiveQueue.Count != 0)
                {
                    timer.LetTimePass(Time.deltaTime);
                }
            }
        }