如图, 运行时加载prefab, 会出现图中的问题, 最终导致30帧-->15帧.
是我的操作有什么问题吗?
这个是有问题的prefab.
可能所有的prefab都有问题, 我仅仅只是列举这一个
加载时卡顿, SkeletonRenderer.Awake方法
根据您提供的情况,加载时出现卡顿和帧数下降的问题可能与几个因素有关。首先,需要确认您的角色或者使用的Spine骨架的顶点数或骨骼数是否非常高,这可能是导致SkeletonRenderer.Awake
方法加载时间长,从而影响性能的原因之一。在Memory Heap SkeletonRenderer的讨论中提到,如果有两个不同的Spine骨架(SkeletonRenderer.Awake
被调用两次),您可以尝试识别是哪一个造成了问题。
此外,如果您在使用SkeletonGraphic
组件,并且遇到了性能问题,Skeleton Graphic WebGL performance issues的讨论建议在GameObject
被禁用时,Unity不会调用Awake()
方法,直到它被启用。这可能不是您想要的大多数情况。因此,一个解决方法可能是开始时将GameObject
启用,然后立即在Start()
调用中禁用它。另一个解决方法是禁用SkeletonGraphic
组件(和其他组件),因为这确实会调用Awake()
方法,与禁用GameObject
相反。
如果您的问题与上述情况不符,建议进一步检查您的Spine资源和Unity项目设置,以确保一切配置正确。由于您的问题描述较为具体,而且涉及到性能优化,通常需要详细分析项目的具体情况才能找到最佳解决方案。
@Init You may want to checkout the following section of the spine-unity documentation:
https://zh.esotericsoftware.com/spine-unity#%E6%80%A7%E8%83%BD%E9%97%AE%E9%A2%98
SkeletonData has to be loaded once. In short: you may want to use binary .skel.bytes
files for faster loading, and use pre-loading of your skeleton e.g. at level start time (or any other not so critical timepoint) instead of loading it at a critical gameplay time point.
Harald
Thank you for your reply. The issue has been resolved, but not using the suggestion you provided. When I was planning to use your suggestion, we held a meeting where we reviewed the updates that occurred a few days before and after the issue arose. We found that the problem occurred while I was using coroutines to load map resources. When I removed the coroutine code, the problem disappeared.
1.Changed the loading from one texture per frame to three textures per frame
2.The issue occurred
3.Reverted to loading one texture per frame
4.The issue disappeared
希望能有所帮助