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. Unity 2022.2 is now available as the latest Tech release.
    Dismiss Notice
  3. We are making some changes to the DOTS forums.
    Dismiss Notice
  4. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

How to use UnitySendMessage on Android

Discussion in 'Android' started by ina, Sep 11, 2012.

  1. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,029
    I have import com.unity3d.player.UnityPlayerActivity (no problem)

    but for some reason I cannot seem to use UnityPlayerActivity.UnitySendMessage ...

    cannot find symbol
    [javac] symbol : method UnitySendMessage(java.lang.String,java.lang.String,java.lang.String)
    [javac] location: class com.unity3d.player.UnityPlayerActivity
    [javac] UnityPlayerActivity.UnitySendMessage("Main Camera","FingerTouch","ypi");
     
  2. Errorsatz

    Errorsatz

    Joined:
    Aug 8, 2012
    Posts:
    555
    What I'm using currently is:

    import com.unity3d.player.*;
    ...
    com.unity3d.player.UnityPlayer.UnitySendMessage("ObjectName", "functionName", "param");
     
  3. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,029
    Where are you putting the sendmessage call? For some reason I cannot seem to receive on the Unity end
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    do you ensure that you call it after Unity is running (not paused from the outside and not on timescale 0) and the game object with the specified function name is present within the scene?
     
  5. Deleted User

    Deleted User

    Guest

    Don't know if you already found it.
    But you are using UnityPlayerActivity.UnitySendMessage
    But that is wrong you need to use UnityPlayer.UnitySendMessage (so not the activity)