How to use multiple param In Animation Event?

I’m trying to use below code in Animation but it’s not working.
Can I use multiple parameter function in Animation?

public void DoSomething(int myInt, string myString) {
Debug.Log(myInt);
Debug.Log(myString);
}

No you cannot do that like this, but you can create a method that accept an animation event as parameter

public void DoSomething(AnimationEvent myEvent) {
Debug.Log(myEvent.floatParameter);
Debug.Log(myEvent.stringParameter);
Debug.Log(myEvent.intParameter);
}
10 Likes

Thanks! but I solved this problem with ‘String.Split();’

1 Like

You have two options:

  • Create a ScriptableObject with the parameters you want and add it to the function as a single parameter.
  • As said by Mecanim-Dev, you can use AnimationEvent parameter, which gives you the option to add 1 of each primitive types (i.e. float, int string) and a “object” which is basically any “Asset object” which you have in your project.
1 Like