diff --git a/assets/core/gui/layer/LayerManager.ts b/assets/core/gui/layer/LayerManager.ts index 979a229..3cee4a4 100644 --- a/assets/core/gui/layer/LayerManager.ts +++ b/assets/core/gui/layer/LayerManager.ts @@ -103,7 +103,7 @@ export class LayerManager { let finalW: number = 0; let finalH: number = 0; - + if (windowAspectRatio > designAspectRatio) { finalH = drs.height; finalW = finalH * ws.width / ws.height; @@ -256,8 +256,13 @@ export class LayerManager { * @param uiArgs 新打开场景参数 */ replace(removeUiId: number, openUiId: number, uiArgs: any = null) { - this.open(openUiId, uiArgs); - this.remove(removeUiId); + const callbacks: UICallbacks = { + onAdded: (node: Node, params: any) => { + this.remove(removeUiId); + } + }; + this.open(openUiId, uiArgs, callbacks); + } /** diff --git a/assets/libs/gui/button/ButtonSimple.ts b/assets/libs/gui/button/ButtonSimple.ts index 9212110..6710454 100644 --- a/assets/libs/gui/button/ButtonSimple.ts +++ b/assets/libs/gui/button/ButtonSimple.ts @@ -23,7 +23,7 @@ export default class ButtonSimple extends Component { type: AudioClip }) private effect: AudioClip = null!; - private effectIds: number[] = []; + // private effectIds: number[] = []; private touchCount = 0; private touchtEndTime = 0; @@ -57,10 +57,11 @@ export default class ButtonSimple extends Component { /** 短按触摸音效 */ protected async playEffect() { if (this.effect) { - const effectId = await oops.audio.playEffect(this.effect, resLoader.defaultBundleName, () => { - this.effectIds.remove(effectId); - }); - if (effectId > 0) this.effectIds.push(effectId); + oops.audio.playEffect(this.effect); + // const effectId = await oops.audio.playEffect(this.effect, resLoader.defaultBundleName, () => { + // this.effectIds.remove(effectId); + // }); + // if (effectId > 0) this.effectIds.push(effectId); } } @@ -68,11 +69,10 @@ export default class ButtonSimple extends Component { this.node.off(Node.EventType.TOUCH_END, this.onTouchEnd, this); this.node.off(Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this); - if (this.effect) { - this.effectIds.forEach(effectId => { - console.log(effectId); - oops.audio.putEffect(effectId, this.effect); - }); - } + // if (this.effect) { + // this.effectIds.forEach(effectId => { + // oops.audio.putEffect(effectId, this.effect); + // }); + // } } } diff --git a/assets/libs/gui/button/UIButton.ts b/assets/libs/gui/button/UIButton.ts index 0e64258..197111a 100644 --- a/assets/libs/gui/button/UIButton.ts +++ b/assets/libs/gui/button/UIButton.ts @@ -27,7 +27,7 @@ export default class UIButton extends Button { type: AudioClip }) private effect: AudioClip = null!; - private effectIds: number[] = []; + // private effectIds: number[] = []; /** 触摸次数 */ private _touchCount = 0; @@ -61,19 +61,20 @@ export default class UIButton extends Button { /** 短按触摸音效 */ protected async playEffect() { if (this.effect) { - const effectId = await oops.audio.playEffect(this.effect, resLoader.defaultBundleName, () => { - this.effectIds.remove(effectId); - }); - if (effectId > 0) this.effectIds.push(effectId); + oops.audio.playEffect(this.effect); + // const effectId = await oops.audio.playEffect(this.effect, resLoader.defaultBundleName, () => { + // this.effectIds.remove(effectId); + // }); + // if (effectId > 0) this.effectIds.push(effectId); } } - onDestroy() { - if (this.effect) { - this.effectIds.forEach(effectId => { - console.log(effectId); - oops.audio.putEffect(effectId, this.effect); - }); - } - } + // onDestroy() { + // if (this.effect) { + // this.effectIds.forEach(effectId => { + // console.log(effectId); + // oops.audio.putEffect(effectId, this.effect); + // }); + // } + // } }