SilverStripe CMS Unity3D Web Player Embedding Issue
I am trying to add the Unity3D (www.unity3d.com) web player into my site with SilverStripe CMS version 2.4.5. What seems to happen is that SS is dynamically removing my code that contains the web player. It leaves a closing div tag.
it is really simple for a simple static page to embed the web player. You need the following code and it works perfectly. HTML:
<script type="tex开发者_C百科t/javascript" src="http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js"></script>
<script type="text/javascript">
<!--
//gets the unityPlayer div and replaces the content with an embed tag which is the web player made by Unity (it works outside of SS.)
function GetUnity() {
if (typeof unityObject != "undefined") {
return unityObject.getObjectById("unityPlayer");
}
return null;
}
//sets the parameters of the web player
if (typeof unityObject != "undefined") {
unityObject.embedUnity("unityPlayer", "MazePuzzle.unity3d", 720, 450);
}
-->
</script>
<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>
it's considered bad practice inserting javascript in you content fields, that's why the wysiwyg editor removes script elements. you can get around this though by configuring tinymce (see this thread for more info how to do this).
a better approach might be using shortcodes, as supported in silverstripe 2.4+. you could end up with something like this in your editor:
[unity width=720 height=450]MazePuzzle.unity3d[/unity]
the docs on shortcodes are a bit sparse, but you can find a good tutorial on this on ssbits
精彩评论