示例#1
0
    IEnumerator Coro()
    {
        var listener = EventBetter.ListenWait <TextMessage>();

        yield return(listener);

        Debug.Log(listener.First.text, this);
    }
示例#2
0
        public IEnumerator TestListenWait()
        {
            using (var listener = EventBetter.ListenWait <TestMessage>())
            {
                Assert.IsNull(listener.Messages);
                Assert.IsNull(listener.First);

                StartCoroutine(WaitAndThen(() =>
                {
                    Assert.IsTrue(EventBetter.Raise(new TestMessage()));
                    Assert.IsTrue(EventBetter.Raise(new TestMessage()));
                }));

                yield return(listener);

                Assert.AreEqual(2, listener.Messages.Count);
                Assert.IsNotNull(listener.First);
                Assert.AreEqual(listener.First, listener.Messages[0]);

                Assert.IsFalse(EventBetter.Raise(new TestMessage()));
            }
        }