Ramesh
Ramesh

Reputation: 633

How to start Unity3d app from mobile browser?

We have an e-learning platform which starts up HTML5 or javascript games and activities. These communicate back to the e-learning platform via web services calls in JSON (calls are wrapped by javascript functions).

We'd like to integrate Unity3d games and activities, but are not clear on how they could be started in an Android or iOS context. We know they can be started in a standard web browser with the Unity3d webplayer plugin. They can also communicate with the page, which is very convenient for us - resembles a javascript element.

What about on an Android phone or an iPad? Our application runs in the mobile browser on these devices. I'm not aware that there is a Unity3d plugin available for mobile browsers. I'm also not aware of any way to start an app from a web page. Is there any way to start a Unity3d app from a mobile browser?

Any suggestions welcome.

Upvotes: 1

Views: 7770

Answers (2)

romaroma
romaroma

Reputation: 658

For Android this link will launch your app (or open the market to suggest install your app):

<a href="intent://something#Intent;scheme=myunityapp;package=com.company.appname;end;">Go to Unity</a>

You will have to setup your AndroidManifest.xml file for you project before, you can build it in few steps:

  1. Specify unique Bundle Identifier in Player Settings before building the app;

  2. Build your apk for one time (it is supposed that you setup your Android development environment before);

  3. Create a folder in Unity: Assets/Plugins/Android;

  4. Copy AndroidManifest.xml file from Your Project/Temp/StagingArea/Android into your fresh Android folder.

  5. Open the AndroidManifest.xml file in the editor, find <intent-filter> tag and add one more <intent-filter> before it:

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myunityapp" android:host="something" />
</intent-filter>
  1. Build the app one more time, upload to your device and install;

  2. Make a sample HTML page with the link above to launch your app.

N.B. Code samples suppose that your Bundle Identifier is com.company.appname, scheme is myunityapp and action is something.

Upvotes: 7

Radu Diță
Radu Diță

Reputation: 14201

You're right in assuming that Unity3d doesn't have players for mobile.

I don't know how to do this for Android but for iOS you can build the Unity project then open up the xCode project that it created and add a custom URL Scheme. This tutorial explains how to do this.

After all this you can create a link in your browser page that uses the URL Schema you created.

 <a href="myunityapp://something">Go to Unity</a>

Note that you need to have a URL Schema that is unique otherwise Safari can open other apps that have the same Schema registered.

Upvotes: 2

Related Questions