如何卸载统一WebGL

问题描述 投票:0回答:1

我正在使用统一的webGL构建,这是在javascript中初始化/加载统一webgl的方法。

 var gameInstance = UnityLoader.instantiate("gameContainer", "Build/WebGLDemo.json", {onProgress: UnityProgress});

但是没有办法卸载webgl。我可以删除canvas标签,但问题是内存中仍有一些资源没有被垃圾回收。另外,当我试图删除

function DeleteGame(){
            console.log("remove game");
            document.getElementById("gameContainer").remove();
            //gameInstance = null;
      }

然后我们得到furstum错误

屏幕位置超出视锥体(屏幕位0.000000,0.000000,0.000000)(摄像头0 0 0 0)

有没有适当的方法来卸载webgl?

c# unity3d unity-webgl
1个回答
0
投票

在Unity 2019 beta中,unity提供了一个内置方法(C#/ JavaScript)来卸载Unity WebGL and cleanup memory

  • C#:调用Application.Quit()
  • JS:调用unityInstance.Quit(回调)

您可以使用C#版本或Javascript:

unityInstance.Quit(function() {
    console.log("done!");
});
unityInstance = null;

有关更多详细信息,请查看unity Forumsunity bug。

我在统一2019.1.0测试版中使用了这个功能,但我不确定它是否是清理内存,但它绝对关闭单元webgl应用程序。

© www.soinside.com 2019 - 2024. All rights reserved.