Creator 2.3.1版本 RichText显示异常问题

  • Creator 版本:

  • 目标平台:

  • 详细报错信息,包含调用堆栈:

  • 重现方式:

  • 之前哪个版本是正常的 :

  • 手机型号 :

  • 手机浏览器 :

  • 编辑器操作系统 :

  • 编辑器之前是否有其它报错 :

  • 出现概率:必现

  • 额外线索:

先问一下引擎组,优化了Label,有对Label做关联性测试吗?

在RichText设置了maxWidth的情况下,动态设置字符串,无法返回正常的长度

    _measureText (styleIndex, string) {
        let self = this;
        let func = function (string) {
            let label;
            if (self._labelSegmentsCache.length === 0) {
                label = self._createFontLabel(string);
                self._labelSegmentsCache.push(label);
            } else {
                label = self._labelSegmentsCache[0];
            }
            label._styleIndex = styleIndex;
            self._applyTextAttribute(label, string, true);
            let labelSize = label.getContentSize();
            return labelSize.width;
        };
        if (string) {
            return func(string);
        }
        else {
            return func;
        }
    },

原因上面的计算宽度的label没有添加到节点上,enabledInHierarchy始终返回false

    _forceUpdateRenderData () {
        if (!this.enabledInHierarchy) return;   // 优化代码

        this.setVertsDirty();
        this._resetAssembler();
        this._applyFontTexture();
    },

官方的解决方案已出,请移步:

https://github.com/cocos-creator/engine/pull/6231/files/bf23273645ae07efa0735537ef5ebf13d17b1030