SilverStripe CMS Unity3D Web 播放器嵌入问题

发布于 2024-10-31 20:08:46 字数 1272 浏览 2 评论 0原文

我正在尝试使用 SilverStripe CMS 版本 2.4.5 将 Unity3D (www.unity3d.com) 网络播放器添加到我的网站中。似乎发生的情况是 SS 正在动态删除我包含网络播放器的代码。它留下一个结束 div 标签。

一个简单的静态页面嵌入网络播放器非常简单。您需要以下代码并且它可以完美运行。 HTML:

<script type="text/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>

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="text/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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧人九事 2024-11-07 20:08:46

在内容字段中插入 javascript 被认为是不好的做法,这就是所见即所得编辑器删除脚本元素的原因。您可以通过配置tinymce来解决这个问题(请参阅此线程了解更多信息来执行此操作)。

更好的方法可能是使用 Silverstripe 2.4+ 中支持的短代码。你最终可能会在编辑器中得到这样的结果:

[unity width=720 height=450]MazePuzzle.unity3d[/unity]

关于短代码的文档有点稀疏,但是您可以在 ssbits

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文