浏览代码

Merge pull request #8998 from CedricGuillemet/nativeLoadScript

adds the ability to loadscript for babylon native
Raanan Weber 4 年之前
父节点
当前提交
52c9d0ffce
共有 1 个文件被更改,包括 14 次插入0 次删除
  1. 14 0
      src/Engines/nativeEngine.ts

+ 14 - 0
src/Engines/nativeEngine.ts

@@ -273,6 +273,20 @@ export class NativeEngine extends Engine {
 
         Tools.Log("Babylon Native (v" + Engine.Version + ") launched");
 
+        Tools.LoadScript = function (scriptUrl, onSuccess, onError, scriptId) {
+            Tools.LoadFile(scriptUrl, (data) => {
+                Function(data as string).apply(null);
+                if (onSuccess) {
+                    onSuccess();
+                }
+            }, undefined, undefined, false,
+            (request, exception) => {
+                if (onError) {
+                    onError("LoadScript Error", exception);
+                }
+            });
+        };
+
         // Wrappers
         if (typeof URL === "undefined") {
             (window.URL as any) = {