web中Texture的 width和height可正常set而在模拟器中却报错

Creator 版本:1.10.2
在web中可设置width与height 但第一次生成 显示出来的图像有问题

第二次生成相同图片后显示正常

在模拟器中则出现报错Simulator: ERROR: TypeError: Attempted to assign to readonly property.

    let url = this._blocks[GameDefine.getRandNumber(0, 5)]; // 图片路径
    let sf = new cc.SpriteFrame();
    sf.setTexture(url);

    sf._texture.width = 63;
    sf._texture.height = 63;

    let sprite = node.getComponent(cc.Sprite);
    sprite.spriteFrame = sf;

WEB中这种情况是否是bug?模拟器中如何正确设置texture的width和height?

防沉补丁v5.0 :sob:

应该是设置spriteFrame的大小

我把 sf._texture.width = 63; sf._texture.height = 63;改成了

   sf._rect.width = 63;
   sf._rect.height = 63;

结果就变成这样了 :9:

getRect setRect之后 还是 同web显示的情况一样

有没有其他思路代码里改动图片大小吗:6:

防沉6.0 :10:

直接给demo吧,我帮你改改 :joy:

demo.zip (861.7 KB)
问题已解决预制中的Size Mode为Trimmed :3: 将其改为Custom后图片显示正常 不需要更改宽高 自己挖坑自己跳:8: