# How to embed unity webplayer built inside phonegap app?

After exporting my game made with unity, I got two files web.html and web.unity3d

I want to embed this game in a phonegap app. I used this code:

<object id="UnityObject"
classid="clsid:444785F1-DE89-4295-863A-D46C3A781394"
width="1024"
height="768"
<param name="Web/Web.unity3d"
value="Web.unity3d" />
<embed id="UnityEmbed"
src="Web/Web.unity3d"
width="1024"
height="768"
type="application/vnd.unity"
pluginspage="http://www.unity3d.com/unity-web-player-2.x" />
</object>


This code works on the browser but nothing shows when I build with xcode.

• It looks like you want to package a chunk of data that is made to be used by a browser plug in into another chunk of data, is that it? I wouldn't think that it's possible because the end-target does not have to tool to understand what the Unity chunk of data is and how to handle it. But I may be wrong. Nov 10 '15 at 14:01

You can't run webplayer builds on smartphones (you shouldn't use the webplayer at all, since it'll be discontinued in 2016)!

You can however export your game as an Xcode project for iOS.

There is also the option of exporting your game as a WebGL application.
The problem here being that
A.) The build will detect mobile browsers and refuse to start * and
B.) The performance will not be good. (expect <10fps)

You should however be able to add native iOS code to your project and run the rest of your phonegap app in a UIWebView.

-- more on the WebGL solution --

UPDATE 1:

I tested a WebGL build in the FirefoxOS Emulator. It worked, but I can not tell you anything about the performance on the actual smartphone or if it works with iOS. It only shows a javascript confirm dialog in the beginning about WebGL and support for mobile deviecs. You should be able to remove this somewhere in a .js file.

UPDATE 2:

OK - I tested the same build on my Xperia Z3 compact running the latest Version of Chrome for Android. While it did work, the framerate was very poor. If your scene is not to complex and you don't mind low end smartphone users suffering through an unplesent experience, you could to it.
BUT YOU SHOULDN'T!

I still can't say anything for iOS, but since they added support for WebGL in Safari, I assume it will work to.

*If you want to remove the annoying popup you get,
just remove the lines 57 to 61 in the /Release/UnityConfig.js-file in your WebGL build.

The Unity webplayer is an NPAPI browser plugin, compiled to run using Intel x86-derived processors on OS X & Windows. There is no NPAPI support in iOS, and the plugin isn't compiled for ARM processors— this is the core reason why what you're trying to do isn't possible.

NPAPI is an old (the “N” stands for “Netscape”) and flawed technology that's on its way out (Chrome no longer supports it), so it's not really what you want even if it sounds like the simplest approach. Follow @RUB3N's advice in his/her answer and use an iOS build instead. It would take some work, but you should be able to integrate the native code Unity spits out with your PhoneGap app.