首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法创建WebGL上下文,统一

无法创建WebGL上下文,统一
EN

Stack Overflow用户
提问于 2022-09-16 19:06:43
回答 2查看 155关注 0票数 0

我的网页上有一个画布,存储在负z索引处。点击一个按钮,我希望团结游戏加载使用统一脚本作为承诺。这个承诺执行得很完美,但是在脚本加载之后,我得到了一个错误

代码语言:javascript
复制
Creating WebGL 2.0 context.
unity.loader.js:1 Unable to create WebGL context.
unity.loader.js:1 exception thrown: TypeError: Cannot read properties of undefined (reading 'getParameter'),TypeError: Cannot read properties of undefined (reading 'getParameter')
    at _glGetString (http://localhost:5500/scripts/unity/Build/unity.framework.js:3:248153)
    at http://localhost:5500/scripts/unity/Build/unity.wasm:wasm-function[29563]:0x8cc821
    at http://localhost:5500/scripts/unity/Build/unity.wasm:wasm-function[25931]:0x82d2c6
    at Module._main (http://localhost:5500/scripts/unity/Build/unity.framework.js:3:299245)
    at callMain (http://localhost:5500/scripts/unity/Build/unity.framework.js:3:364104)
    at doRun (http://localhost:5500/scripts/unity/Build/unity.framework.js:3:364664)
    at run (http://localhost:5500/scripts/unity/Build/unity.framework.js:3:364836)
    at runCaller (http://localhost:5500/scripts/unity/Build/unity.framework.js:3:363763)
    at Object.removeRunDependency (http://localhost:5500/scripts/unity/Build/unity.framework.js:3:16089)
    at http://localhost:5500/scripts/unity/Build/unity.framework.js:3:1948
    at doCallback (http://localhost:5500/scripts/unity/Build/unity.framework.js:3:92358)
    at done (http://localhost:5500/scripts/unity/Build/unity.framework.js:3:92512)
    at transaction.oncomplete (http://localhost:5500/scripts/unity/Build/unity.framework.js:3:85617)

我有一个背景粒子效应,它使用requestAnimationFrame()运行,在统一脚本开始使用cancelAnimationFrame()加载之前结束。

我在网上找不到多少

EN

回答 2

Stack Overflow用户

发布于 2022-09-17 10:04:05

因此,经过30分钟的调试,问题是画布的上下文设置为2d,而统一构建是3d的。创建了一个新的画布元素,问题就解决了。

票数 0
EN

Stack Overflow用户

发布于 2022-09-17 10:56:12

上下文丢失在任何WebGL构建中都会发生,并且与统一无关。我找不到关于这个问题的任何细节,并且在不重新加载网页的情况下修复它。这很可能是由于浏览器中的上下文数量或它们的内存受到限制所致。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73749336

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档