
this.scheduleOnce(()=>{
获取Size
},0)
这个行吗
不行,0改成0.05都不行,0.1就获取到了,太难受了
按他的注释
2.对 Layout 设置后结果需要到下一帧才会更新,除非你设置完以后手动调用。[[updateLayout]]
应该没问题
是不是layout或者父节点active为false 或者子节点也在变化?
我去试试
就是类似这样,我把数字9改成99999,然后调用updateLayout(true),要延迟0.1秒才能获取到真实宽度
,没其它任何操作了
试了一下 label下一帧刷新宽度,layout下下帧刷新
Label调一下updateRenderer
const ui = this.layout.node.getComponent(UITransform);
this.label.string = `啊啊啊啊啊啊啊`;
console.log(ui.width);//40
this.label.updateRenderer()
console.log(ui.width);//40
this.layout.updateLayout(true);
console.log(ui.width);//140
3赞
非常感谢