问题描述
通常我使用这样的文件初始值设定项来实例化 SCNParticleSystems:
Usually I instantiate SCNParticleSystems by using the file initializer like this:
var stars = SCNParticleSystem(named: "Stars.sncp", inDirectory: nil)
但是,这个项目需要一个 Swift Playground,当我尝试将该 init 函数与存储在 Playground 的 Resources 文件夹中的系统一起使用时,它返回 nil(即使我将指定的目录更改为Resources"或/Resources"等).)
However this project requires a Swift Playground and when I try to use that init function with systems stored in the playground's Resources folder it returns nil (even if I change the specified directory to "Resources" or "/Resources" etc. etc. ).
Playground 资源路径的处理方式是否与普通应用程序不同,还是我犯了一个非常愚蠢的文件命名错误?
Are Playground resource paths handled differently to normal apps or am I making a really stupid filenaming mistake?
推荐答案
我认为您在文件扩展名方面做错了.它是 .scnp 而不是 .sncp.
I think you're doing a mistake in filename extension. It is .scnp and not .sncp.
要么尝试不使用任何扩展名 -
Either try without any extension -
var stars = SCNParticleSystem(named: "Stars", inDirectory: nil)
或尝试使用正确的扩展名 -
or try with correct extension -
var stars = SCNParticleSystem(named: "Stars.scnp", inDirectory: nil)
这篇关于Swift Playground 中的 SceneKit 粒子系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!