SceneKit编辑器为节点设置了自定义类 [英] SceneKit editor set custom class for node

查看:155
本文介绍了SceneKit编辑器为节点设置了自定义类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在SpriteKit编辑器中,我可以为SKNode分配一个自定义类,如下所示:

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

但是,我似乎在SceneKit编辑器中找不到等效的功能.它甚至存在吗?而且,如果我不能为SCNNode设置自定义类,是否有没有该功能的原因,或者Xcode团队没有解决这个问题? (换句话说,我应该提雷达吗?)

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

推荐答案

您不能在场景编辑器中执行此操作.而且您可能根本不应该这样做.您必须实现自己的序列化代码(以便SCNScene加载正确进行).并且所有用于搜索节点的方法(按名称,命中测试,在一个卷内)均返回SCNNode,因此您将永远投射结果.

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.

对于每个Apple开发人员,SCNScene都不是子类,我认为这会扩展到SCNNode.改写扩展名.

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

请参阅:

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

这篇关于SceneKit编辑器为节点设置了自定义类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆