You add a "Listener" to any scripts which you want to receive the event.
public void Awake()
{
Messenger.AddListener<GameObject, int>("keycardSelected", OnKeycardSelected); // OnKeycardSelected is the name of the void method below.
// The "signature" is <GameObject, int> because we're going to pass the keycard GameObject and an int for the keycard number.
}
public void OnKeycardSelected(GameObject keycard, int keycardNumber)
{
}
Then anywhere else in the project, Broadcast the event:
Messenger.Broadcast<GameObject, int>("keycardSelected", keycardGameObject, 1);
All the best,
Mark
On 7 October 2012 14:48, Scott Baker
<scot...@gmail.com> wrote:
Hey Mark,
Having some issues with the messenger. I'm broadcasting when the keycard is picked up
Messenger.Broadcast("keycard1Selected", Keycard1Used);
(Keycard1Used is a variable that activates when I have it selected)
The question is, in my door script, how do I tell the listener to call a certain void within the script
to act upon it.
Could you give me an example when you've some time?
Thanks,
- Scott.