Function not Appearing in Animation Window? [C#]

For some reason, I can’t seem to call this function from an event in the Animation Window. Here’s the code:

public void BroadcastAMessage(string name, string function)
    {
        GameObject temp = GameObject.Find(name) as GameObject;

        temp.BroadcastMessage(function);

        return;
    }

Appreciate any help; hopefully just a rookie mistake :slight_smile:

I’m 99% sure that the function has to be parameterless.

Thanks for the reply. Tried your suggestion and got some interesting results:

Apparently, animation events can only take 1 parameter (I tried to pass 2). What’s more, I can’t seem to pass it a class/object as a parameter; it says “Function Not Supported”!

Anyone know a way around this?

In case anybody else runs into this, a somewhat hackish work around is to just take 1 string parameter, and cut it up into the information you need via string.Split(). This is what I ended up doing:

public void BroadcastAMessage(string param)
{
        string[] words = param.Split(',');

        GameObject temp = GameObject.Find(words[0]) as GameObject;

        temp.BroadcastMessage(words[1],SendMessageOptions.DontRequireReceiver);

        return;
}

Would be nice if Unity could support multiple params out-the-box, but this works for now :slight_smile:

It seems that bool parameters are not supported as well…