我正在尝试让SCORM 1.2与我们的Unity 5 WebGL项目一起工作。
我想我会逐步引入SCORM代码;以下是我想“翻译”的代码,以便在Unity中工作:
var vault = {}; //vault 'namespace' helps ensure no conflicts with possible other "SCORM" variables
vault.UTILS = {}; //For holding UTILS functions
vault.debug = { isActive: true }; //Enable (true) or disable (false) for debug mode
vault.SCORM = { //Define the SCORM object
version: null, //Store SCORM version.
handleCompletionStatus: true, //Whether or not the wrapper should automatically handle the initial completion status
handleExitMode: true, //Whether or not the wrapper should automatically handle the exit mode
API:{handle: null, isFound: false}, //Create API child object
connection: { isActive: false }, //Create connection child object
data: { completionStatus: null, exitStatus: null}, //Create data child object
debug:{} //Create debug child object
};
当我使用该代码时,Unity告诉我
'Utils' is not a member of 'Boo.Lang.Hash'
好的。有人告诉我应该使用哈希表,而不是普通的ol'javascript项目。到目前为止,我得到的是:
var vault:Hashtable = new Hashtable(); //vault 'namespace' helps ensure no conflicts with possible other "SCORM" variables
vault['UTILS'] = new Hashtable(); //For holding UTILS functions
vault['debug'] = new Hashtable(); //Enable (true) or disable (false) for debug mode
vault['debug']['isActive'] = true;
vault['SCORM'] = { //Define the SCORM object
version: null, //Store SCORM version.
handleCompletionStatus: true, //Whether or not the wrapper should automatically handle the initial completion status
handleExitMode: true, //Whether or not the wrapper should automatically handle the exit mode
API:{handle: null, isFound: false}, //Create API child object
connection: { isActive: false }, //Create connection child object
data: { completionStatus: null, exitStatus: null}, //Create data child object
debug:{} //Create debug child object
};
但现在Unity抛出以下错误:
Type 'Object' does not support slicing
……在
vault['debug']['isActive'] = true;
线
如何将属性添加到嵌套在变量中的Hashtable?