Пример #1
0
        // Update is called once per frame
        void Update()
        {
            if (Input.GetKeyDown(KeyCode.Alpha1))
            {
                Message sMessage = new Message();
                sMessage.Type   = "START";
                sMessage.Filter = "Filter";
                sMessage.Data   = "你好,我是有过滤标识的信息";
                //MessageDispatcher发送一条信息出去,信息的标识为"START",过滤标识为"Filter"。
                MessageDispatcher.SendMessage(sMessage);
            }

            if (Input.GetKeyDown(KeyCode.Alpha2))
            {
                Message sMessage = new Message();
                sMessage.Type = "START";
                sMessage.Data = "你好~~~我是一条延迟发送的消息";
                //延迟1秒后才发送
                sMessage.Delay = 1f;
                //MessageDispatcher发送一条信息出去,信息的标识为"START"。
                MessageDispatcher.SendMessage(sMessage);
            }

            if (Input.GetKeyDown(KeyCode.Alpha3))
            {
                MyCustomMessage mcm = new MyCustomMessage();
                mcm.MyCustomString = "我是自定义消息的额外数据";
                mcm.Type           = "Custom";
                MessageDispatcher.SendMessage(mcm);
            }
        }
Пример #2
0
        // Update is called once per frame
        void Update()
        {
            if (Input.GetKeyDown(KeyCode.Alpha1))
            {
                Message sMessage = new Message();
                sMessage.Type   = "START";
                sMessage.Filter = "Filter";
                sMessage.Data   = "Hello, I have filtered information";
                //MessageDispatcher sends a message out, the message identifier is "START", and the filter identifier is "Filter".
                MessageDispatcher.SendMessage(sMessage);
            }

            if (Input.GetKeyDown(KeyCode.Alpha2))
            {
                Message sMessage = new Message();
                sMessage.Type = "START";
                sMessage.Data = "Hello~~~I am a delayed message";

                //Send after 1 second delay
                sMessage.Delay = 1f;

                //MessageDispatcher sends a message out, the identifier of the message is "START".
                MessageDispatcher.SendMessage(sMessage);
            }

            if (Input.GetKeyDown(KeyCode.Alpha3))
            {
                MyCustomMessage mcm = new MyCustomMessage();
                mcm.MyCustomString = "I am the extra data of the custom message";
                mcm.Type           = "Custom";
                MessageDispatcher.SendMessage(mcm);
            }
        }