UnitySendMessage : Object does not have receiver

Hi,

I am trying to use the UnitySendMessage function in my App. The problem is that I get the message:

The setup is rather simple. I have a script named animationController.js attached to an object named Hero.

This script contain a function Run as follows:

function Run(msg:String)
{
	this.animation.wrapMode = WrapMode.Once;
	this.animation.CrossFade("WalkRun");
	this.animation.wrapMode = WrapMode.Loop;
	this.animation.CrossFade("RunForward");
	currentAction = run;
}

This script runs very well from within unity. I have no problem whatsoever with it.

My call in XCode is the following:

UnitySendMessage("Hero", "Run", "text");

I have done many tries including:

  • Change the name of the object Hero in the call. In this case, the message says that there is no such object. I conclude that the object Hero is found and sound.
  • Change the name of the methode for something like animationController.Run; but this does not help a bit.
  • I checked in the Assembly-UnityScript.dll file and I do find my script function. The Run one looks like this:
m_animationController_Run_string:
_m_4:

	.byte 13,192,160,225,128,64,45.......etc.

Considering the number of people who actually succeed in using UnitySendMessage, I must be doing something wrong but I cannot spot that very thing.
Any help is very much appreciated.

Thanks.

I know this is a very old thread, but I was seeing the same error when using a Firebase WebGL bridge - it turns out the GameObject name you are trying to communicate with must be unique. So in this instance, you may have had multiple game objects named ‘Hero’.

I had tidied up my hierarchy by having a ‘Logic’ object to hold MonoBehaviours associated with a particular subsystem or module. When getting a response from the webpage, it would look to respond to a gameObject called ‘Logic’ - of which I had multiple, and only one had the required entry point.