I am trying to use the Unity3d ActiveX control from within the .Net WebBrowser control.
I published the sample island project provided by Unity and when I open the generated html file in IE8 on Windows 7, everything works fine. I checked the "Allow active content to run in files on My Computer" option in the IE advanced options, so I do not get the security prompt about running the ActiveX control.
However, when I try to do the same in the WebBrowser control, the VBScript in the html file that attempts to create the ActiveX control fails.
set tControl = CreateObject("UnityWebPlayer.UnityWebPlayer.1")
Is there a trick to getting the Unity3d ActiveX control to work in the WebBrowser control?
It looks like this is specific to the WebPlayer ActiveX because the first .html file using the Windows Media Player ActiveX object loads correctly in IE8 and in the WebBrowser control. The second .html file works in IE8 but fails to create the WebPlayer ActiveX object in the WebBrowser control.
From this post on the forum, http://forum.unity3d.com/viewtopic.php?p=203996#203996, I assume that using the WebPlayer ActiveX from inside the WebBrowser control is possible though.
Windows Media Player HTML
<html>
<head>
<title>WMP Test</title>
</head>
<body>
<script language="JavaScript">
var WMP7;
WMP7 = new ActiveXObject("WMPlayer.OCX.7");
if ( WMP7 )
{
document.write ('<OBJECT ID=MediaPlayer ');
document.write (' CLASSID=CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6');
document.write (' standby="Loading Microsoft Windows Media Player components..."');
document.write (' TYPE="application/x-oleobject" width="400" height="400">');
document.write ('<PARAM NAME="url" VALUE="http://download.microsoft.com/download/5/7/1/57139364-d7af-4c18-9ce3-5149a3a727ca/EC304_Friend.wmv">');
document.write ('<PARAM NAME="AutoStart" VALUE="false">');
document.write ('<PARAM NAME="ShowControls" VALUE="1">');
document.write ('<PARAM NAME="uiMode" VALUE="mini">');
document.write ('</OBJECT>');
}
</script>
</body>
</html>
WebPlayer HTML
<html>
<head>
<title>Unity Test</title>
</head>
<body>
<script language="JavaScript">
var Unity;
Unity = new ActiveXObject("UnityWebPlayer.UnityWebPlayer.1");
if ( Unity )
{
document.write ('<OBJECT ID=UnityObject ');
document.write (' CLASSID=CLSID:444785F1-DE89-4295-863A-D46C3A781394');
document.write (' TYPE="application/vnd.unity" width="400" height="300">');
document.write ('<PARAM NAME="src" VALUE="IslandDemo.unity3d">');
document.write ('<PARAM NAME="pluginspage" VALUE="http://www.unity3d.com/unity-web-player-2.x">');
document.write ('</OBJECT>');
}
</script>
</body>
</html>