Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

UnitySendMessage : Object does not have receiver

Discussion in 'iOS and tvOS' started by BusyBee, Jul 17, 2013.

  1. BusyBee

    BusyBee

    Joined:
    Jul 17, 2013
    Posts:
    1
    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:

    Code (csharp):
    1. function Run(msg:String)
    2. {
    3.     this.animation.wrapMode = WrapMode.Once;
    4.     this.animation.CrossFade("WalkRun");
    5.     this.animation.wrapMode = WrapMode.Loop;
    6.     this.animation.CrossFade("RunForward");
    7.     currentAction = run;
    8. }
    This script runs very well from within unity. I have no problem whatsoever with it.

    My call in XCode is the following:

    Code (csharp):
    1. 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:
      Code (csharp):
      1. m_animationController_Run_string:
      2. _m_4:
      3.  
      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.
     
  2. Vixxd

    Vixxd

    Joined:
    Jul 25, 2016
    Posts:
    11
    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.