求教:sprite获取不到兄弟节点下面的子节点

结构如下,nextBtn绑定的脚本中获取main下面的节点mainBall,如果用
this.node.getParent().getChildByName(‘main’).getChildByName(‘mainBall’)获取到node,但是执行mainBall中的方法会报错not function。
通过this.node.getParent().getChildByName(‘main’).getComponentInChildren(‘mainBall’)获取则获取不到。
求教,如何获取?getComponentInChildren和getChildByName不应该是一样的吗?
image

报错截图:
image

getComponentInChildren -> 递归查找所有子节点中第一个匹配指定类型的组件
getChildByName -> 通过名称获取节点的子节点
一个获取的是组件,一个获取的是节点。

1赞

请问如何获取?其他地方是getComponentInChildren获取的可以执行函数,但是这里获取不到

this.node.getParent().getChildByName(‘main’).getComponentInChildren(‘mainBall’)
这种方式获取的是Null

脚本没挂载