Пример #1
0
 private void Start()
 {
     //注册普通类型事件
     TypeEventSystem.Register <Data>(ReceiveClassData);
     //注册自动回收类型事件
     TypeEventSystem.Register <PoolableData>(ReceivePoolableData);
     Debug.LogFormat($"<color=#00ffffff>按“S”键发送事件,按“U”键注销事件</color>");
 }
Пример #2
0
        void Update()
        {
            //发送事件
            if (Input.GetKeyDown(KeyCode.S))
            {
                TypeEventSystem.Send(new Data {
                    Name = "普通类型事件"
                });
                TypeEventSystem.Send <PoolableData>();
            }

            //注销事件
            if (Input.GetKeyDown(KeyCode.U))
            {
                Debug.LogFormat($"<color=#00ffffff>注销事件</color>");
                TypeEventSystem.UnRegister <Data>(ReceiveClassData);
                TypeEventSystem.UnRegister <PoolableData>(ReceivePoolableData);
            }
        }