Subclassing SCNScene and SceneKit Editor

前端 未结 3 1204
无人共我
无人共我 2021-01-28 02:18

I have SCNScene subclass with a camera setup, that I want to use in all the subclasses.

let scene01 = TheSubclassScene()
let scene02 = TheSubclassScene(named:\"a         


        
3条回答
  •  滥情空心
    2021-01-28 02:50

    .scn files are just SCNScene instances archived and written to disk using NSKeyedArchiver. What + sceneNamed: does is that it simply unarchives the scene with a NSKeyedUnarchiver.

    What you could do then, is to try to use - setClass:forClassName: to instantiate a subclass instead of a SCNScene.

    That being said, SCNScene is not really meant to be subclassed. Instead you could implement your logic in the view controller or a game controller (possibly a direct subclass of NSObject). This controller will also likely conform to SCNSceneRendererDelegate to implement your game logic.

提交回复
热议问题