Browse Source

敌人死亡音效报错解决

181404010226 1 month ago
parent
commit
50b83d9b1b

+ 1 - 1
assets/Scenes/GameLevel.scene

@@ -45650,7 +45650,7 @@
         "__id__": 1329
       }
     ],
-    "_active": true,
+    "_active": false,
     "_components": [
       {
         "__id__": 1332

+ 2 - 2
assets/scripts/AudioManager/AudioManager.ts

@@ -127,7 +127,7 @@ export class AudioManager extends Component {
         console.log(`[AudioManager] 发起音乐播放请求#${requestId}: ${musicPath}`);
         
         try {
-            const bundlePath = musicPath.replace('data/', '');
+            const bundlePath = musicPath.replace('data/', '').replace(/\.(mp3|wav|ogg)$/i, '');
             const clip = await this.bundleLoader.loadAssetFromBundle<AudioClip>('data', bundlePath, AudioClip);
 
             // 若在加载期间有新的播放请求,丢弃本次播放
@@ -221,7 +221,7 @@ export class AudioManager extends Component {
         }
         
         try {
-            const cleanPath = sfxPath.replace('data/', '');
+            const cleanPath = sfxPath.replace('data/', '').replace(/\.(mp3|wav|ogg)$/i, '');
             const bundlePath = cleanPath;
             const clip = await this.bundleLoader.loadAssetFromBundle<AudioClip>('data', bundlePath, AudioClip);
             

+ 2 - 2
assets/scripts/AudioManager/EnemyAudios.ts

@@ -78,7 +78,7 @@ export class EnemyAudios extends Component {
         
         // 如果还是没有有效音效路径,使用默认音效
         if (!soundPath || soundPath === 'Null' || soundPath === 'nan' || soundPath === '') {
-            soundPath = '弹球音效/hammer1.mp3'; // 默认攻击音效
+            soundPath = 'data/弹球音效/hammer1'; // 默认攻击音效
         }
         
         // 获取音量设置
@@ -105,7 +105,7 @@ export class EnemyAudios extends Component {
         
         // 如果还是没有有效音效路径,使用默认音效
         if (!soundPath || soundPath === 'Null' || soundPath === 'nan' || soundPath === '') {
-            soundPath = '弹球音效/normal zombie die 1.mp3'; // 默认死亡音效
+            soundPath = 'data/弹球音效/normal zombie die 1'; // 默认死亡音效
         }
         
         // 获取音量设置