Xcode 11 Action Editor? How to invoke?

左心房为你撑大大i 提交于 2021-02-11 04:33:29

问题


In an earlier post I asked about the right settings for initializing a SCNParticleEngine. With some hints from Zay

I managed to get both the SCNP and code paths to work – almost identically. Except that the SCNP path had the particles shrinking over time while the coding path did not.

Turns out that buried inside the SCNP file is a dictionary entry “Size” which is a SCNParticlePropertyController. Here’s the code from the debugger:

The gotcha is that when I open the SCNP file in the editor, I can see the stars being animated etc. But there is no sign of an Action or any affordance to open such an editor. Now, this may be related to the fact that the SCNP file is all about the PE parameters for initializing the PE. There is NOT an actual node or object on the stage. One thought is you need to have an editable action or Xcode won’t open the Action editor?

How this action got there or how I might edit it is not clear. I assume someone put it in the SCNP in an earlier version of Xcode. Then the Action was forgotten. Or something like that. It may simply be a bug/corrupted SCNP file.


回答1:


As you mention this is Core Animation animation driving SCNParticlePropertySize. It is possible to configure it in the SceneKit scene editor via the Attributes inspector (not the Action editor).




回答2:


To be able to control the size of your particles over time (i.ex. let them shrink) using code only, you have to use a SCNPropertyController and a CAKeyframeAnimation like so:

// ANIMATE PARTICLE SIZE OVER TIME
let animationSize                   = CAKeyframeAnimation()
animationSize.values                = [0.7, 0.3,   0.2, 0.0]
animationSize.keyTimes              = [0.0, 0.125, 0.3, 1.0]
animationSize.duration              = CFTimeInterval(10.0)
animationSize.calculationMode       = .cubic
animationSize.timingFunction        = CAMediaTimingFunction.init(name: .linear)

and then you do:

// SET PROPERTY CONTROLLER
let sizeController = SCNParticlePropertyController(animation: animationSize)
myParticleSystem.propertyControllers = [SCNParticleSystem.ParticleProperty.size: sizeController]

with the same approach you can animate the particle colours in a changing sequence over time.



来源:https://stackoverflow.com/questions/65958867/xcode-11-action-editor-how-to-invoke

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!