Exemplo n.º 1
0
        public NotificationElement GetElement()
        {
            NotificationElement element = objects.Dequeue();

            element.FadeIn();

            return(element);
        }
Exemplo n.º 2
0
        IEnumerator Notify(string text, Color color)
        {
            NotificationElement element = pool.GetElement();
            float duration = settings.Duration;

            element.SetText(text);
            element.SetColor(color);

            yield return(new WaitForSeconds(duration));

            pool.AddElement(element);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates pool for notification elements.
        /// </summary>
        /// <param name="parent">Parent transform of pool.</param>
        /// <param name="amount">Pool size.</param>
        public NotificationPool(Transform parent, int amount)
        {
            prefab  = Resources.Load <GameObject>("Prefabs/NotificationElement");
            objects = new Queue <NotificationElement>();

            for (int i = 0; i < amount; i++)
            {
                NotificationElement element = Object.Instantiate(prefab, parent).GetComponent <NotificationElement>();

                AddElement(element);
            }
        }
Exemplo n.º 4
0
 public void AddElement(NotificationElement element)
 {
     element.FadeOut();
     objects.Enqueue(element);
 }