SceneKit editor set custom class for node

醉酒当歌 提交于 2019-12-08 03:59:51

问题


In the SpriteKit editor, I can assign a custom class to an SKNode, like so:

However, I can't seem to find the equivalent functionality in the SceneKit editor. Does it even exist? And if I can't set a custom class for an SCNNode, is there a reason the feature isn't there, or has the Xcode team just not gotten around to it? (In other words, should I file a radar?)


回答1:


You can't do it in the scene editor. And you probably shouldn't do it at all. You'll have to implement your own serialization code (so that SCNScene loading works correctly). And all of the methods for searching nodes (by name, hit test, within a volume) return SCNNode, so you'll be forever casting your results.

Per Apple developers, SCNScene is not meant to be subclassed, and I think that extends to SCNNode. Write an extension instead.

See:

  • Trouble subclassing SCNScene
  • Subclassing SCNNode
  • Subclassing SCNScene and SceneKit Editor


来源:https://stackoverflow.com/questions/44921638/scenekit-editor-set-custom-class-for-node

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