由于 StandaloneInputModule,场景需要 20 秒才能加载

Scene takes 20secs to load because of StandaloneInputModule

我的主要场景需要 20 秒才能加载,在 运行 分析器之后它指向 StandaloneInputModule 因为它需要那么多时间。

我在项目中搜索了那个脚本,但它不存在,我只找到了 StandaloneInput

¿我在哪里可以找到这个 script/reduce 这个加载时间?

StandaloneInputModule 位于您项目中的事件系统游戏对象中,它负责您正在开发的游戏中的输入:)

问题本质上是您的游戏中可能有大量世界 space UI 画布。这些 canvases 中的每一个都有一个 "graphics raycaster" 脚本,因为我认为它们会在您创建 canvas 时自动放在那里(可能是错误的)。只需删除所有这些 canvases 上的所有图形光线投射检查。事件系统不得不尝试跟踪所有这些对象,因此 "Eventsystem.Update()" 真的很难过。摆脱那些 "graphic raycaster" 脚本为我的游戏节省了大量 CPU 时间。

好消息是 "Event System" 脚本和 "Input module" 脚本本身的性能并不差。这对我来说是个好消息,因为我认为它是在 Unity 的末端,结果不是(除非你需要大量的图形 raycaster 检查)。

和平!