在节点层次结构中搜索不起作用,结果为零

问题描述

这里是我场景结构的图片

Scene Hierarchy

我正在尝试执行命中测试以获取 RootNode 以旋转和缩放节点。

不幸的是,当我执行命中测试时,我得到的结果是 Cube_Material_001_0,这是纹理。

我在代码添加了 func childNode(withName:,recursively) 以找到“RootNode”,但结果始终为零。

这里是我使用的代码

func getNodeHit(at position: CGPoint) -> SCNNode {
            guard let hitResult = sceneView.hitTest(position,options: nil).first  else {return SCNNode()}
            guard let nodeParent = hitResult.node.childNode(withName: "RootNode",recursively: true) else {return SCNNode()}
            
            print("Node touch \(String(describing: nodeParent.name))")
            return hitResult.node
        }

为什么我找不到“RootNode”?我如何获得 RootNode?​​p>

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)