Search Results for

    Show / Hide Table of Contents

    Receiving Messages via Component

    Using GlobalMessage’s MessageReceiver component allows you to receive Messages without the need to edit or create code and components. This is especially useful in situations where you just want to augment existing systems with the ability to receive Messages without changing their underlying code.

    The MessageReceiver component is used by assigning methods of other components to its OnMessageReceived UnityEvent directly in the Editor. The assigned methods are invoked whenever the selected MessageType is sent.


    The following example shows how to set up Message reception using the MessageReceiver component.

    In the Editor, add the MessageReceiver component to the desired GameObject. Then, select the EMO you want to receive.

    In the component's OnMessageReceived UnityEvent, assign the method you want to invoke upon reception of the Message.

    Now, whenever the selected Message is sent, the assigned method is called.

    Inspector of MessageReceiver component.


    Receiving Messages with Parameter

    Receiving Messages with parameter via the MessageReceiver component essentially works the same. The only difference is that you can assign methods to the OnMessageReceived event that take the same parameter type in addition to methods without parameters.

    Inspector of MessageReceiver component with parameter.

    In This Article
    Back to top Malte HusungLeave a ReviewLegal Noticethank you ❤️