0
votes

As the title says, I have an existing Android project and I want to import Unity classes.jar so I can access the UnityPlayer.UnitySendMessage.

I found this other question with similar goal, but the answers were unintelligible or unhelpful.

I also found this on the Unity forums, but it is apparently very outdated (2011).

Essentially, all I'm trying to do is:

  1. Open up an Android application.
  2. Select which scene (or, preferably, more than one scene) I want to view from the Unity app.
  3. Launch the Unity GearVR application.
  4. Play the selected scene(s).

I've already got steps 1 and 3 working, and steps 2 and 4 I'm making work by loading each scene up as a different APK and launching a specific APK depending on which scene I want to view, but, ideally, I could host all the scenes in a single application so I could then watch several off the scenes in a row (and also so I could cut down significantly on memory usage).

I've found some tutorials on using UnityPlayer.UnitySendMessage, so I think I can get it working if I can only get Android Studio to recognize and use UnityPlayer.UnitySendMessage, but if you have any other ideas, I appreciate those as well!

1

1 Answers

0
votes

I've found some tutorials on using UnityPlayer.UnitySendMessage, so I think I can get it working if I can only get Android Studio to recognize and use UnityPlayer.UnitySendMessage

Get classes.jar from one of the sub-folders from

<UnityInstallationDirectory>\Editor\Data\PlaybackEngines\AndroidPlayer\Variations\mono

or

<UnityInstallationDirectory>\Editor\Data\PlaybackEngines\AndroidPlayer\Variations\il2cpp

depending on if you are using mono or IL2CPP as Scripting Backend to build your Android Project.

Import it into Android Studio. Right-click on it and click Add As library and Android Studio should add it as library. See this if you are still confused. You can now use UnityPlayer.UnitySendMessage.

As for the rest of your question, I think that you should look into this answer. It explains how you can show Unity scene in a sub-view. That is another way to get what you want.