主要 Bug,XCAssets 文件夹中创建的 Sprite Atlas 不支持批量渲染 [英] Major Bug, Sprite Atlas created in XCAssets Folder does not support batch rendering

查看:18
本文介绍了主要 Bug,XCAssets 文件夹中创建的 Sprite Atlas 不支持批量渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始在 XCAssets 文件夹中使用新的 Sprite Atlas,而不是将我的地图集放在项目文件夹中.但是我注意到,当我这样做时,我的节点不再被批量渲染,这导致了大量低效的绘图调用.这完全违背了使用图集的目的!

I started using the new Sprite Atlas in the XCAssets folder instead of having my atlases in the project folder. However I noticed that when I did this my nodes were no longer being batch rendered which resulted in a large number of inefficient draw calls. This completely defeats the purpose of using an atlas!

要明确的是,这是我用来获取图集的代码.

To be clear this is the code I used to get the atlas.

let atlas = SKTextureAtlas(named: "Sprites")

Sprites"是在 XCAssets 文件夹中创建的 Sprite Atlas.

有没有人有解决方法,或者我在项目文件夹中制作 Sprite Kit Atlases.

Does anyone have a workaround or am I stuck making Sprite Kit Atlases in the project folder.

我正在使用 Xcode 7.2 测试版.

I'm using Xcode 7.2 beta.

我之所以要使用新的 Sprite Kit Atlases 是因为 这个问题.

The reason why I want to use the new Sprite Kit Atlases is because of this issue.

推荐答案

我在输入问题时找到了一种解决方法.您可以通过 XCAssets 文件夹中的图像以编程方式创建 SKTextureAtlas,如下所示:

I found one workaround as I was typing the question. You can create a SKTextureAtlas programmatically from images inside the XCAssets folder like so:

let atlas = SKTextureAtlas(dictionary: ["Head":UIImage(named: "Head")!, "Body":UIImage(named: "Body")!])

这显然只是一种解决方法.希望 Apple 在更高版本的 Sprite Kit 中修复此问题.这是一个非常严重的性能错误,所有开发人员都应该注意.甚至 Apple 的示例项目也使用了新的 Sprite Atlases,因此您认为它们可以进行批量渲染.

This is obviously just a workaround. Hopefully Apple fixes this in later versions of Sprite Kit. This is a pretty serious performance bug that all developers should be aware of. Even Apple's sample project uses the new Sprite Atlases so you think they would have batch rendering working.

更新 1苹果的回应:

感谢您告知我们这个问题.我们正在调查原因,并将在未来的 iOS 中加入修复更新.同时,您可以应用两种解决方法:1. 在 .atlas 文件夹中创建和使用纹理图集.2. 继续在资产目录中使用纹理图集,但部署目标设置为 iOS 8.0.

Thanks for letting us know about this issue. We are currently investigating the cause, and will be incorporating a fix in future iOS updates. In the mean time, there are two workarounds you can apply: 1. Create and use texture atlas in a .atlas folder. 2. Continuing using texture atlas in the asset catalog, but with deployment target set to iOS 8.0.

更新 2苹果表示可能已经在 iOS 10 中修复.正在调查.

Update 2 Apple said may have been fixed in iOS 10. Going to investigate.

这篇关于主要 Bug,XCAssets 文件夹中创建的 Sprite Atlas 不支持批量渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆