Ejemplo n.º 1
0
 // ------------------
 static public int Compare(NotificationElementGUI a, NotificationElementGUI b)
 {
     if ((a == null) || (b == null))
     {
         return(0);
     }
     if (a.IsActive() != b.IsActive())
     {
         return(a.IsActive() ? -1 : 1);
     }
     if (!a.IsActive())
     {
         return(0);
     }
     return((a.elapsed == b.elapsed) ? 0 : (a.elapsed < b.elapsed) ? -1 : 1);
 }
Ejemplo n.º 2
0
        // ------------------
        void OnEnable()
        {
            if (CFUtils.editorStopped)
            {
                return;
            }

            this.maxNotifications = Mathf.Max(this.maxNotifications, 1);

            if (this.notificationTemplate == null)
            {
                return;
            }

            this.notificationTemplate.gameObject.SetActive(false);

            while (this.notificationList.Count < maxNotifications)
            {
                this.notificationList.Add(null);
            }

            for (int i = 0; i < this.notificationList.Count; ++i)
            {
                if (this.notificationList[i] == null)
                {
                    this.notificationList[i] = (NotificationElementGUI)NotificationElementGUI.Instantiate(this.notificationTemplate);
                }

                this.notificationList[i].End();
                this.notificationList[i].transform.SetParent(this.notificationListBox, false);
            }


            GamepadManager.onGamepadActivated    += this.OnGamepadActivated;
            GamepadManager.onGamepadConnected    += this.OnGamepadConnected;
            GamepadManager.onGamepadDisconnected += this.OnGamepadDisconnected;
            GamepadManager.onGamepadDisactivated += this.OnGamepadDisactivated;
        }
Ejemplo n.º 3
0
        // -----------------
        private void AddNotification(string msg, Sprite icon) //, Color color, Texture2D icon = null)
        {
            if (string.IsNullOrEmpty(msg))
            {
                return;
            }

            NotificationElementGUI notification = null;

            for (int i = 0; i < this.notificationList.Count; ++i)
            {
                NotificationElementGUI n = this.notificationList[i];
                if (n == null)
                {
                    continue;
                }

                if (!n.IsActive())
                {
                    notification = n;
                    break;
                }
                else if ((notification == null) || (n.GetTimeElapsed() > notification.GetTimeElapsed()))
                {
                    notification = n;
                }
            }

            if (notification == null)
            {
                return;
            }

            notification.End();
            notification.Show(msg, icon, this.notificationListBox, this.msgDuration);

            this.SortNotifications();
        }