Esempio n. 1
0
        void Start()
        {
            Logger.text = string.Empty;
            Debug.Log("Starting Messaging Test");
            Counts = 0;

            var m  = new ExampleMessage();
            var m2 = new CachedExampleMessage();

            Messenger.Subscribe(this);
            Messenger.Publish(m);
            Assert(() => Counts == 2, "Sub Then Pub");

            Messenger.Unsubscribe(this);
            Messenger.Publish(m2);
            Messenger.Subscribe(this);
            Messenger.ClearCache();
            Assert(() => Counts == 3, "Cached Sub / Pub");

            Messenger.Unsubscribe(this);
            Messenger <object> .Subscribe(ObjectHandler);

            Messenger.Publish(m);
            Messenger.Publish(m2);
            Assert(() => Counts == 5, "Manual Sub / Pub");

            Debug.Log("All Done");
        }
        IEnumerator Start()
        {
            Logger.text = string.Empty;
            Debug.Log("Starting Messaging Test");
            yield return new WaitForSeconds(1);
            Counts = 0;

            var m = new ExampleMessage();
            var m2 = new CachedExampleMessage();

            Messenger.Subscribe(this);
            Messenger.Publish(m);
            Assert(() => Counts == 2, "Sub Then Pub");
            yield return new WaitForSeconds(1);

            Messenger.Unsubscribe(this);
            Messenger.Publish(m2);
            Messenger.Subscribe(this);
            Messenger.ClearCache();
            Assert(() => Counts == 3, "Cached Sub / Pub");
            yield return new WaitForSeconds(1);

            Messenger.Unsubscribe(this);
            Messenger<object>.Subscribe(ObjectHandler);
            Messenger.Publish(m);
            Messenger.Publish(m2);
            Assert(() => Counts == 5, "Manual Sub / Pub");
            yield return new WaitForSeconds(1);

            Debug.Log("All Done");
        }
 public void Handler(CachedExampleMessage m)
 {
     Counts++;
     Debug.Log("Handling CachedExampleMessage");
 }
Esempio n. 4
0
 public void Handler(CachedExampleMessage m)
 {
     Counts++;
     Debug.Log("Handling CachedExampleMessage");
 }