动态添加EditBox,TEXT_LABEL,还有另一个LABEL位置偏左上。
编辑器创建的EditBox,这两个Label的锚点默认设置为0,1
但动态创建的EditBox不会。
看了edit-box.ts源码中
_updateLabelPosition方法,假设了两个Label的锚点就是0,1
offY + size.height

const trans = this.node._uiProps.uiTransformComp!;
const offX = -trans.anchorX * trans.width;
const offY = -trans.anchorY * trans.height;
const placeholderLabel = this._placeholderLabel;
const textLabel = this._textLabel;
if (textLabel) {
textLabel.node._uiProps.uiTransformComp!.setContentSize(size.width - LEFT_PADDING, size.height);
textLabel.node.setPosition(offX + LEFT_PADDING, offY + size.height, textLabel.node.position.z);
if (this._inputMode === InputMode.ANY) {
textLabel.verticalAlign = VerticalTextAlignment.TOP;
}
textLabel.enableWrapText = this._inputMode === InputMode.ANY;
}
if (placeholderLabel) {
placeholderLabel.node._uiProps.uiTransformComp!.setContentSize(size.width - LEFT_PADDING, size.height);
placeholderLabel.lineHeight = size.height;
placeholderLabel.node.setPosition(offX + LEFT_PADDING, offY + size.height, placeholderLabel.node.position.z);
placeholderLabel.enableWrapText = this._inputMode === InputMode.ANY;
}
有很多其实只是源码上的小问题,但却没法单独测试和发布新的版本,这一点是我很疑惑的。


3.8正式版官方支持了更换slot图片 很棒, 但是我想getAttachment 改color…发现 升级之后 getAttachment 里面不含color的属性了… ? 原本有的这些属性都没有了鸭.