Unity 报错之 Scope was not disposed, You should use the ‘using‘ keyword or manually call Dispose.
Posted 陈言必行
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Unity 报错之 Scope was not disposed, You should use the ‘using‘ keyword or manually call Dispose.相关的知识,希望对你有一定的参考价值。
Unity 报错之 Scope was not disposed! You should use the 'using' keyword or manually call Dispose.
发生错误
本地环境:
- Mac版本:11.2.2
- Unity版本:2019.2.0f1
导致报错的操作:
工程为android平台,想修改游戏图标,点击了 Project Setting
--> Player
--> Default Icon
然后Player也没就不见了,并且点击报错,如下图:
报错信息
报错截图
详细信息
Scope was not disposed! You should use the ‘using’ keyword or manually call Dispose.
UnityEngine.Scope:Finalize()
GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced.
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
ArgumentException: GUILayout: Mismatched LayoutGroup.repaint
UnityEngine.UIElements.UIR.RenderChain.Render (UnityEngine.Rect topRect, UnityEngine.Matrix4x4 projection) (at /Users/unity/buildslave/unity/build/Modules/UIElements/Renderer/UIRChainBuilder.cs:238)
UnityEngine.UIElements.UIRRepaintUpdater.DrawChain (UnityEngine.Rect topRect, UnityEngine.Matrix4x4 projection) (at /Users/unity/buildslave/unity/build/Modules/UIElements/Renderer/UIRRepaintUpdater.cs:66)
UnityEngine.UIElements.UIRRepaintUpdater.Update () (at /Users/unity/buildslave/unity/build/Modules/UIElements/Renderer/UIRRepaintUpdater.cs:54)
UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTree () (at /Users/unity/buildslave/unity/build/Modules/UIElements/VisualTreeUpdater.cs:72)
UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event e) (at /Users/unity/buildslave/unity/build/Modules/UIElements/Panel.cs:637)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at /Users/unity/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:240)
UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at /Users/unity/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:78)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at /Users/unity/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
解决方案
方法一:
切换平台:先切换到PC,在切换回来。然后编辑器就正常了。
实现方法:找到Build Settings
面板 --> 选择PC
--> 点击Switch Platform
然后等待切换完成,再切换回来。
方法二:
打安卓包:打包APK或者导出Android工程后,编辑器就正常了。
实现方法:找到Build Settings
面板 --> 点击Export
或者 Build
。 然后等待打包完成即可。
编辑器正常后:禁用 Metal Editor Support 会更改编辑器 API(重新启动 Editor),然后重新启用 Metal 支持(再次重新启动 Editor)和错误消失了。
其他方法
若你尝试了上述方法,那么可以看下面链接里的回答,尝试其他解决办法:
参考地址
以上是关于Unity 报错之 Scope was not disposed, You should use the ‘using‘ keyword or manually call Dispose.的主要内容,如果未能解决你的问题,请参考以下文章
Unity报错之UnityException: Texture ‘XXX‘ is not readable
Unity 报错之 打包安卓闪退 Could not allocate memory: System out of memory
Unity 报错之 打包安卓闪退 Could not allocate memory: System out of memory
vscode c++编译报错:‘nullptr’ was not declared in this scope(-std=c++11)
Unity 之 切换语言导致报错:System.FormatException:String was not recognized as a valid DateTime.
Unity 之 切换语言导致报错:System.FormatException:String was not recognized as a valid DateTime.