Example #1
0
        void OnStart()
        {
            // 监听父类事件
            ILTypeEventSystem.Register <SomeBaseEvent>(OnSomeBaseEvent);

            Observable.EveryUpdate().Subscribe(_ =>
            {
                if (Input.GetMouseButtonDown(0))
                {
                    // 发送 ABC 事件
                    // 要指定父类事件,父类事件就能接收到
                    ILTypeEventSystem.Send <SomeBaseEvent>(new ABCEvent());
                }
            })
            .AddTo(gameObject);
        }
Example #2
0
        void OnStart()
        {
            // 注册事件
            ILTypeEventSystem.Register <SomeEvent>(OnSomeEvent);


            Observable.EveryUpdate().Subscribe(_ =>
            {
                // 鼠标左键点击
                if (Input.GetMouseButtonDown(0))
                {
                    // 发送事件(不传参数)
                    ILTypeEventSystem.Send <SomeEvent>();

                    // 发送事件(传参数)
                    ILTypeEventSystem.Send(new SomeEvent()
                    {
                        SomeValue = 123
                    });
                }
            }).AddTo(gameObject);
        }
Example #3
0
 void OnDestroy()
 {
     // 注销事件
     ILTypeEventSystem.UnRegister <SomeEvent>(OnSomeEvent);
 }
Example #4
0
 void OnDestroy()
 {
     ILTypeEventSystem.UnRegister <SomeBaseEvent>(OnSomeBaseEvent);
 }