Skip to content

Conversation

@zhefengzhang
Copy link
Contributor

@zhefengzhang zhefengzhang commented Oct 9, 2025

Re: #
native 平台中,sprite 组件在没有 spriteFrame 时无法设置透明度值,需要在 sprite 组件更新 spriteFrame 时让其更新一次透明度值并作用到 ui 渲染上。
In native platform, sprite component can't set transparency value without spriteFrame. You need to let sprite component update transparency value once when spriteFrame is updated and apply it to ui rendering.

test bug code:

import { _decorator, Component, Node, Sprite, SpriteFrame } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('NewComponent')
export class NewComponent extends Component {

    @property(Sprite)
    testSp: Sprite = null;

    @property(SpriteFrame)
    testSpf: SpriteFrame = null;

    start() {
        this.node.on(Node.EventType.TOUCH_END, this.test, this);
    }

    test () {
        if(this.testSp){
            var targetColor = this.testSp.color.clone();
            targetColor.a = 30;
            this.testSp.color = targetColor;
            setTimeout(()=>{
                this.testSp.spriteFrame = this.testSpf;
                console.log(`target Color alpha is ${this.testSp.color.a}`);
            })
        }
    }
}

@github-actions
Copy link

github-actions bot commented Oct 9, 2025

Code Size Check Report

Wechat (WASM) Before After Diff
2D Empty (legacy pipeline) 1009805 bytes 1009779 bytes 👍 -26 bytes
2D All (legacy pipeline) 2675364 bytes 2675338 bytes 👍 -26 bytes
2D All (new pipeline) 2767100 bytes 2767074 bytes 👍 -26 bytes
(2D + 3D) All 10024070 bytes 10024044 bytes 👍 -26 bytes
Web (WASM + ASMJS) Before After Diff
(2D + 3D) All 16843132 bytes 16843106 bytes 👍 -26 bytes

Interface Check Report

This pull request does not change any public interfaces !

@zhefengzhang
Copy link
Contributor Author

@cocos-robot run test cases

1 similar comment
@zhefengzhang
Copy link
Contributor Author

@cocos-robot run test cases

@github-actions
Copy link

@zhefengzhang, Please check the result of run test cases:

Task Details

Platform build boot runned crashScene FailScene
web-mobile PASS PASS PASS
ios PASS PASS FAIL rt-read-pixels
mac PASS PASS PASS

@github-actions
Copy link

@zhefengzhang, Please check the result of run test cases:

Task Details

@sushanhong
Copy link
Contributor

@cocos-robot run test cases

@zhefengzhang
Copy link
Contributor Author

zhefengzhang commented Nov 13, 2025

@star-e star-e merged commit 0726f9b into cocos:v3.8.8 Nov 14, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants