Bug问题
webgl的项目中,偶尔会出现以下错误:
An exception has occurred, but exception handling has been disabled in this build. If you are the developer of this content, enable exceptions in your project WebGL player settings to be able to catch the exception or see the stack trace.
有道翻译后为:
发生异常,但在此生成中已禁用异常处理。如果你是这个内容的开发者,在你的项目WebGL播放器设置中启用异常可以捕捉异常或者看到堆栈跟踪。
Bug解决方案
将Enable Exceptions 从 None,改为
Explicitly Thrown Exceptions Only或者Full Without Stacktrace重新打包即可。
Bug排查
1.想法
想到项目中的打包设置的Publishing Settings中的Enable Exceptions异常输出被设置成了None,应该是跟这个有关。
2.手写bug
写一个简单的调用空物体的报错bug。
public class Bug : MonoBehaviour
{
public GameObject obj;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.A))
{
obj.transform.position = Vector3.zero;
}
if (Input.GetKeyDown(KeyCode.S))
{
Debug.Log(obj.name);
}
}
}
挂到场景物体上,不给obj赋值.
3.unity运行
按A或S正常报错。
4.打包测试
分别以Enable Exceptions 为 None、
Explicitly Thrown Exceptions Only、Full Without Stacktrace三种情况打包。
5. 测试结果
None 出现提示框bug
Explicitly Thrown Exceptions Only 无提示框bug,web控制台检测到错误
Full Without Stacktrace 无提示框bug,web控制台检测到错误
谢谢阅读,如果对你有帮助可以给我点个赞,或者加个收藏,方便以后查看