I’m not much of a web developer, but over the last few weeks my work has made me learn a lot about jqury and javascript, so I figured I would put that into effect.

So, I made an overlay function in javascript and jquery that would create a frame for unity play in and append it to the content div for wordpress, so It would dynamically load content. This is a much better way for me to show off samples and demos then directing to a new page so I figured it was worth the effort. I included the code in the link below, Personally I just dropped this into the theme header so it would be loaded, and then use a link to call the javascript function like so.

<a href=”javaScript:UnityApp(
‘http://www.aWebPage.com/WebPlayer.unity3d’,
1000,600, ‘GameTitle’);”>LinkText</a>

 

<script type="text/javascript" src=
"http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js">
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"
type="text/javascript"></script>
<script type="text/javascript">

function UnityApp(unityApp, width, height, title) {
	$("#content").append("<div id='unityWindow'
style='background-color:#000000; position:absolute;
text-align:right; width:" + (width + 20) + "px; height:" +
(height + 40) + "px'><div id='title' style='color:white;
font-size:150%;'>" + title + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href='javascript:closeUnityApp()'>X</a></div><div id='unityPlayer'>
</div></div>");

$("html, body").animate({ scrollTop: 0 }, "fast");
	unityObject.embedUnity("unityPlayer", unityApp, width, height);

}

function closeUnityApp() {
	$("#unityWindow").remove();
}

</script>