Exemple #1
0
        /*
         * public static bool PostNotification<T>(object sender, T notification, bool bNotifyEntity = false) where T : Notification
         * {
         *  if (sender == null) throw new ArgumentNullException("sender");
         *  if (notification == null) throw new ArgumentNullException("notification");
         *
         *  if (sender is INotificationDispatcher)
         *  {
         *      return (sender as INotificationDispatcher).PostNotification<T>(notification, bNotifyEntity);
         *  }
         *  else if (GameObjectUtil.IsGameObjectSource(sender))
         *  {
         *      if (bNotifyEntity)
         *      {
         *          var dispatcher = GameObjectUtil.GetGameObjectFromSource(sender).AddOrGetComponent<GameObjectNotificationDispatcher>();
         *          return dispatcher.PostNotification<T>(notification, bNotifyEntity);
         *      }
         *      else
         *      {
         *          var dispatcher = GameObjectUtil.GetGameObjectFromSource(sender).GetComponent<GameObjectNotificationDispatcher>();
         *          return dispatcher != null && dispatcher.PostNotification<T>(notification, bNotifyEntity);
         *      }
         *  }
         *  else
         *  {
         *      throw new System.ArgumentException("Sender is not a NotificationDispatcher.", "sender");
         *  }
         * }
         */

        #endregion

        #region Purge/Clean Utilities

        public static void PurgeHandlers(UnityEngine.GameObject go)
        {
            foreach (var c in go.GetComponentsAlt <INotificationDispatcher>())
            {
                c.Observers.PurgeHandlers();
            }
        }