【发布时间】:2016-09-20 19:00:46
【问题描述】:
我正在尝试将 Unity 5 WebGL 项目与 SCORM 1.2 集成。这涉及到 Unity WebGL 构建与一些外部 javascript 通信。
我找到了这个页面:
https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html
...这建议将外部 js 放在 Assets/Plugins/WebGL 文件夹中,并将文件保存为 .jslib 文件。这是我的临时 SCORM.jslib 文件的外观:
var SCORM = {
Hello: function()
{
window.alert("Hello, world!");
console.log("Hello function in SCORM.jslib has been called.");
}
}
然后,在附加到我的游戏对象触发器(一个立方体)的 C# 脚本中:
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
public class CompletionTrigger : MonoBehaviour {
[DllImport("__Internal")]
private static extern void Hello();
void Start () {
Hello();
}
void Update () {
}
}
问题是我在调用 'Hello()' 的那一行遇到了 'EntryPointNotFoundException' 错误。
我在这里用谷歌搜索过,但答案似乎与开发 C++ dll 或 RoR 有关。
有谁知道是什么导致了这个错误? 谢谢。
编辑
我在另一个页面上看到一条评论说错误只出现在编辑器中,所以我想我会再次运行 WebGL 构建。我收到以下错误:
Failed running "C:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport/BuildTools/Emscripten_Win/python/2.7.5.3_64bit/python.exe" "C:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport/BuildTools/Emscripten/emcc" @"D:/Projects/Unity 3D/Packaging Test/Assets/../Temp/emcc_arguments.resp"
stdout:
WARNING: sanity check failed to run [Errno 13] Permission denied: 'C:\\Program Files\\Unity\\Editor\\Data\\PlaybackEngines\\WebGLSupport/BuildTools/emscripten.config_sanity'
stderr:
WARNING root: did not see a source tree above or next to the LLVM root directory (guessing based on directory of C:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport/BuildTools/Emscripten_FastComp_Win\llc), could not verify version numbers match
INFO root: (Emscripten: Running sanity checks)
WARNING root: java does not seem to exist, required for closure compiler, which is optional (define JAVA in ~/.emscripten if you want it)
error: failure to execute js library "D:\Projects\Unity 3D\Packaging Test\Assets\Plugins\WebGL\SCORM.jslib": ReferenceError: window is not defined,,ReferenceError: window is not defined
错误消息持续了一段时间,但我在这里包含的最后一行似乎表明编译器不知道如何处理“窗口”,说它没有定义。那里还提到了“健全性检查”,这似乎很贴切。
再次,如果有人有任何指示,将不胜感激。
【问题讨论】:
标签: javascript c# unity3d scorm