Skip to content

Commit

Permalink
fix spine opacity failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
Canvasfull committed Jul 18, 2023
1 parent ec88dc5 commit b1869be
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
9 changes: 8 additions & 1 deletion cocos/2d/components/ui-opacity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

import { ccclass, disallowMultiple, editable, executeInEditMode, executionOrder, help, menu, serializable, tooltip } from 'cc.decorator';
import { JSB } from 'internal:constants';
import { EDITOR_NOT_IN_PREVIEW, JSB } from 'internal:constants';
import { Component } from '../../scene-graph/component';
import { misc } from '../../core';
import { UIRenderer } from '../framework/ui-renderer';
Expand Down Expand Up @@ -67,6 +67,13 @@ export class UIOpacity extends Component {
this.node._uiProps.localOpacity = value / 255;

this.setEntityLocalOpacityDirtyRecursively(true);

if(EDITOR_NOT_IN_PREVIEW) {
setTimeout(()=>{
EditorExtends.Node.emit('change', this.node.uuid, this.node);
}, 200);
}

}

private setEntityLocalOpacityDirtyRecursively (dirty: boolean) {
Expand Down
1 change: 1 addition & 0 deletions cocos/spine/assembler/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export const simple: IAssembler = {
function updateComponentRenderData (comp: Skeleton, batcher: Batcher2D) {
comp.drawList.reset();
if (comp.color.a === 0) return;
comp._updateColor();
_premultipliedAlpha = comp.premultipliedAlpha;
_useTint = comp.useTint || comp.isAnimationCached();
if (comp.isAnimationCached()) {
Expand Down
8 changes: 6 additions & 2 deletions cocos/spine/skeleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1490,12 +1490,16 @@ export class Skeleton extends UIRenderer {
}
}

protected _updateColor () {
/**
* @engineInternal
*/
public _updateColor (): void {
//if(EDITOR_NOT_IN_PREVIEW) cce.Node.emit('change-node', this.node);
this.node._uiProps.colorDirty = true;
const r = this._color.r / 255.0;
const g = this._color.g / 255.0;
const b = this._color.b / 255.0;
const a = this._color.a / 255.0;
const a = this.node._uiProps.opacity;
this._instance.setColor(r, g, b, a);
}

Expand Down

0 comments on commit b1869be

Please sign in to comment.