1

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

enter image description here

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?)

PopKernel
  • 4,110
  • 5
  • 29
  • 51

1 Answers1

3

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:

Hal Mueller
  • 7,019
  • 2
  • 24
  • 42
  • Why is a SCNNode not meant to be subclassed ? Who says that, Apple ? Where can we read about best practices then ? – omarojo May 04 '18 at 01:21
  • I don't think I can add anything to the three SO questions I linked to. If you think you need to subclass it, that deserves a separate question that describes what you really want to do. – Hal Mueller May 04 '18 at 02:09
  • "You can't do it in the scene editor." Is that still the case? it's really bizarre. – Fattie Nov 11 '22 at 19:50