加了widget后如何获取到节点的真实高度呢?

RT,我在场景中创建了一个节点,并在节点上添加了一个widget组件,当在1920X1080的屏幕下,节点上的widget设置 TOP:832px,BOTTOM:832px,此时高度是256,当在长屏手机中,这个节点会被拉高,但是我打印这个节点的高度(console.log(this.node.height))时显示的仍然时256;于是我直接打印了这个节点(console.log(this.node)),然后展开对象,发现里面的height是674.56.如图:


代码如下:
start(){
console.log(“this.node.height:”, this.node.height);
console.log(“this.node:”, this.node);
}
我要怎样才能获取到这个 674.56呢?

node.getComponent(cc.Widget).updateAlignment();就行了

1赞

非常感谢您的回答