Hey there!
We had some performance issues when instantiating SkeletonGraphic
components and it seems that loading the skeleton data + atlas is pretty pricey (skeletons are exported as bytes)
We fixed it by loading these assets (calling SkeletonDataAsset.GetSkeletonData
) in another thread which seems to be working great; loading time is decreased in about 75% and no exceptions thrown / weird issues occur (for now 🙂)
However I'm not sure it's fully safe - would love to hear some thoughts on where/when it might cause issues/crashes for us
Pseudo code:
//Dummy, we'll probably get these from an asset bundle IRL
[SerializeField] private List<SkeletonDataAsset> skeletonsData;
//Called during the app load phase, so safe to assume there won't be other objects that'll call GetSkeletonData
public void LoadSkeletonData()
{
UniTask.RunOnThreadPool(LoadSkeletonDataInternal).Forget();
}
private void LoadSkeletonDataInternal()
{
foreach (SkeletonDataAsset skeletonData in skeletonsData)
skeletonData.GetSkeletonData(true); //didn't change the source code for now, should we implement a lock?
}
*This is for a mobile game