Skip to content

Commit

Permalink
Add _setParentOpacity and revert accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
dumganhar committed Jan 13, 2025
1 parent e54f325 commit 0b9b092
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions cocos/2d/components/ui-opacity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function setEntityLocalOpacityDirtyRecursively (
const uiOp = node.getComponent(UIOpacity);
if (uiOp && stopRecursiveIfHasOpacity) {
// Because it's possible that UiOpacity components are handled by themselves (at onEnable or onDisable)
uiOp._parentOpacity = parentOpacity;
uiOp._setParentOpacity(parentOpacity);
return;
}

Expand All @@ -75,7 +75,7 @@ function setEntityLocalOpacityDirtyRecursively (
if (render && render.color) { // exclude UIMeshRenderer which has not color
render.renderEntity.colorDirty = dirty;
if (uiOp) {
uiOp._parentOpacity = parentOpacity;
uiOp._setParentOpacity(parentOpacity);
render.renderEntity.localOpacity = parentOpacity * uiOp.opacity / 255;
} else {
// there is a just UIRenderer but no UIOpacity on the node, we should just transport the parentOpacity to the node.
Expand All @@ -89,7 +89,7 @@ function setEntityLocalOpacityDirtyRecursively (
if (uiOp) {
// there is a just UIOpacity but no UIRenderer on the node.
// we should transport the interrupt opacity downward
uiOp._parentOpacity = parentOpacity;
uiOp._setParentOpacity(parentOpacity);
parentOpacity = parentOpacity * uiOp.opacity / 255;
}

Expand Down Expand Up @@ -131,16 +131,18 @@ export class UIOpacity extends Component {
* @zh
* 父节点的opacity。
*
* @engineInternal
* @mangle
*/
public _parentOpacity: number = 1.0;
private _parentOpacity: number = 1.0;

/**
* @engineInternal
* @mangle
*/
public _parentOpacityResetFlag: boolean = true;
_setParentOpacity (v: number): void {
this._parentOpacity = v;
}

private _parentOpacityResetFlag: boolean = true;

/**
* @en
Expand Down

0 comments on commit 0b9b092

Please sign in to comment.