Passing a structure in SendMessage

Hi I am trying to pass more than 1 parameters using SendMessage, I read that I can do it by accepting a structure as parameter in my function. But I do not actually know how to pass my structure.

I did it this way, but I think it is wrong.

In my Script A:

struct bombStruct{
		int flag = 1;
		Transform bombLocation = transform;

gameObject.SendMessage("explodeEffect", new bombStruct {flag, bombLocation}, SendMessageOptions.DontRequireReceiver);

In my Script B which receives the function call:

IEnumerator explodeEffect(bombStruct bombInfo){
       Debug.Log(bombInfo.flag + bombInfo.bombLocation);

Make that structure a -public- class. Other than that it looks ok.

In ur case the structure is private, thats c#'s default and the other script may not have access to it.

In case it’s not clear why I said class in the first sentence:
I’d go with a class as it’s easier to pass things around by reference rather than copying the object around.

That’s considered a good practice I believe - to have the new class in a separate file. Just remember that you don’t have to inherit from MonoBehaviour (or anything in that case)

new bombStruct (flag, bombLocation)