Skip to content

Commit

Permalink
Update onEnable function
Browse files Browse the repository at this point in the history
  • Loading branch information
yoki0805 committed Oct 12, 2024
1 parent 60e0f7a commit e3f30f2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cocos/2d/components/ui-opacity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,14 @@ export class UIOpacity extends Component {
}

public onEnable (): void {
this.node.on(NodeEventType.PARENT_CHANGED, this._parentChanged, this);
this.node._uiProps.localOpacity = this._parentOpacity * this._opacity / 255;
if (this._parentOpacityResetFlag) {
this._parentChanged();
this._parentOpacityResetFlag = false;
} else {
this._setEntityLocalOpacityRecursively(this.node._uiProps.localOpacity);
}
this.node.on(NodeEventType.PARENT_CHANGED, this._parentChanged, this);
this.node._uiProps.localOpacity = this._parentOpacity * this._opacity / 255;
this._setEntityLocalOpacityRecursively(this.node._uiProps.localOpacity);
}

public onDisable (): void {
Expand Down

0 comments on commit e3f30f2

Please sign in to comment.