Hello, Unity community!
I am looking to have a game play in the unity web player on an educational social network website that I am helping to develop for a course of mine.
I am using the WAMP (windows apache mysql php) web development platform to run Buddypress.
I’ve added some test code as a plugin on the social network that you can see below.
I pretty much just copied the html code that unity generated and put it in the format that BuddyPress wants php plugin files to be in.
<?php
/*
Plugin Name: unitygametest
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
Description: Opens a unity web player and plays a test game
Version: 1.0
Author: Ross Peterson
Author URI: http://website_of_the_author
License: GPL
*/
function unitygametest()
{
//The UnityObject script has to be loaded before it can be used.
//This is done at the top of the <head> section.
//$unityWebPlayer_PorcufishPirates =
//'
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Unity Web Player | WebPlayer</title>
<script type="text/javascript" src="http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js"></script>
<script type="text/javascript">
<!--
function GetUnity() {
if (typeof unityObject != "undefined") {
return unityObject.getObjectById("unityPlayer");
}
return null;
}
if (typeof unityObject != "undefined") {
unityObject.embedUnity("unityPlayer", "WebPlayer_PorcufishPirates.unity3d", 960, 640);
//unityObject.embedUnity("unityPlayer", "WebPlayer_PorcufishPirates.jpg", 960, 640);
}
-->
</script>
<style type="text/css">
<!--
body {
font-family: Helvetica, Verdana, Arial, sans-serif;
background-color: white;
color: black;
text-align: center;
}
a:link, a:visited {
color: #000;
}
a:active, a:hover {
color: #666;
}
p.header {
font-size: small;
}
p.header span {
font-weight: bold;
}
p.footer {
font-size: x-small;
}
div.content {
margin: auto;
width: 960px;
}
div.missing {
margin: auto;
position: relative;
top: 50%;
width: 193px;
}
div.missing a {
height: 63px;
position: relative;
top: -31px;
}
div.missing img {
border-width: 0px;
}
div#unityPlayer {
cursor: default;
height: 640px;
width: 960px;
}
-->
</style>
</head>
<body>
<p class="header"><span>Unity Web Player | </span>WebPlayer</p>
<div class="content">
<div id="unityPlayer">
<div class="missing">
<a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">
<img alt="Unity Web Player. Install now!" src="http://webplayer.unity3d.com/installation/getunity.png" width="193" height="63" />
</a>
</div>
</div>
</div>
<p class="footer">« created with <a href="http://unity3d.com/unity/" title="Go to unity3d.com">Unity</a> »</p>
</body>
</html>
<?php
//';
//echo $unityWebPlayer_PorcufishPirates;
}
?>
Then I just makes sure the function gets called in the top level index.php file
if(function_exists('unitygametest'))
{
unitygametest();
}
When I visit the site, the html that should run the plugin is ‘executed’ and the unity web player shows up to tell me that it “Failed to download the data file”
After doing some googling, I’ve noticed that some people needed to add the MIME type files to their servers.
So I found two mime.type files in my wamp directory and found the following:
application/vnd.unity unityweb
just to be sure, I changed it recognize/accept the .unity3d extension:
application/vnd.unity unityweb unity3d
That still didn’t work so I opened Apache’s httpd.conf and added this to the “AddType” section:
AddType application/vnd.unity .unity3d .unityweb
That didn’t change anything and I noticed that someone had gotten help on a similar issue by changing this line in the html:
unityObject.embedUnity(“unityPlayer”, “WebPlayer_PorcufishPirates.unity3d”, 960, 640);
into:
unityObject.embedUnity(“unityPlayer”, “WebPlayer_PorcufishPirates.jpg”, 960, 640);
which apparently fools the MIME type restrictions on certain servers.
But that didn’t make a difference.
I’ve also made sure that my .unity3d file is in fact named “WebPlayer_PorcufishPirates” as is called for in the .html file.
This same naming setup works just fine in the folder on my desktop that Unity generated when I first built the WebPlayer version. It only doesn’t work when I put the .html and .unity3d files in in the buddypress social network server’s plugin directory. Finally, I also tried generating a version with the UnityObject.js file and putting that down in that with the .html and .unity3d.
I’m at my wit’s end with this.
Does anybody have any idea’s why it “Failed to download the data file”???