在大型项目中经常遇到新旧模型替换的问题,如果没有一个好的替换习惯很容易造成模型Mesh丢失的情况。unity在切换场景的时候会因为模型丢失报错
例如:
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.InternalStaticBatchingUtility.CombineGameObjects (UnityEngine.GameObject[] gos, UnityEngine.GameObject staticBatchRoot, System.Boolean isEditorPostprocessScene, UnityEngine.InternalStaticBatchingUtility+StaticBatcherGOSorter sorter) (at <2e0a48134cc845028fb11656fdc79d23>:0)
UnityEngine.InternalStaticBatchingUtility.Combine (UnityEngine.GameObject staticBatchRoot, System.Boolean combineOnlyStatic, System.Boolean isEditorPostprocessScene, UnityEngine.InternalStaticBatchingUtility+StaticBatcherGOSorter sorter) (at <2e0a48134cc845028fb11656fdc79d23>:0)
UnityEditor.UnityBuildPostprocessor.OnProcessScene (UnityEngine.SceneManagement.Scene scene, UnityEditor.Build.Reporting.BuildReport report) (at <23d96447c030422fb76b5c08cdcf57cc>:0)
UnityEditor.Bui

文章讲述了在大型Unity项目中,新旧模型替换可能导致的Mesh丢失问题,这会引起运行时错误。作者提供了一段C#代码,用于检测并定位丢失Mesh的模型,帮助开发者及时发现和修复问题。这段代码在场景加载后通过空格触发,打印出丢失Mesh的GameObject路径。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



