Re:

12 views
Skip to first unread message

Sergio Calabria

unread,
Oct 8, 2012, 4:47:35 AM10/8/12
to unity3d...@googlegroups.com

Thanks man! Just saw the alerts ;)

On Oct 8, 2012 9:44 AM, "Mark Aherne" <fae...@gmail.com> wrote:
Hi Scott,

Here is a link to my version of the Messenger: https://dl.dropbox.com/u/80660114/Messenger.cs

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.


Sergio Calabria

unread,
Oct 8, 2012, 4:48:07 AM10/8/12
to unity3d...@googlegroups.com

Not proper thread reply :)

Mark Aherne

unread,
Oct 8, 2012, 4:54:35 AM10/8/12
to unity3d...@googlegroups.com
Hmm sorry? Thread reply? To Scott? I wanted to share the reply with the group.

Just back in Dublin now so I'm going through my mail.
Reply all
Reply to author
Forward
0 new messages