2024-08-08 12:19:32 +08:00
|
|
|
|
using System.Collections.Generic;
|
2024-07-08 15:28:18 +08:00
|
|
|
|
using System.ComponentModel;
|
2024-08-08 12:19:32 +08:00
|
|
|
|
using Cysharp.Threading.Tasks;
|
2024-10-12 15:32:21 +08:00
|
|
|
|
using UnityEngine;
|
2024-07-08 15:28:18 +08:00
|
|
|
|
|
|
|
|
|
|
public partial class SROptions
|
|
|
|
|
|
{
|
|
|
|
|
|
[Category("音频")]
|
|
|
|
|
|
[DisplayName("音频ID")]
|
2024-07-24 16:41:58 +08:00
|
|
|
|
public string AudioKey
|
2024-07-08 15:28:18 +08:00
|
|
|
|
{
|
|
|
|
|
|
set;
|
|
|
|
|
|
get;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Category("音频")]
|
|
|
|
|
|
[DisplayName("播放音频")]
|
|
|
|
|
|
public async void Play()
|
|
|
|
|
|
{
|
2024-07-24 16:41:58 +08:00
|
|
|
|
int audioID = AudioManager.Instance.PlayAudio(AudioKey);
|
2024-07-08 15:28:18 +08:00
|
|
|
|
if (audioID < 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("Debug, Audio播放失败,请检查AudioID!");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-07-08 16:47:36 +08:00
|
|
|
|
|
2024-10-12 15:32:21 +08:00
|
|
|
|
[Category("音频")]
|
|
|
|
|
|
[DisplayName("播放载具停止音频")]
|
|
|
|
|
|
public async void _PlayTest()
|
|
|
|
|
|
{
|
|
|
|
|
|
var audioName = "Sound_armoredcar_stop";
|
|
|
|
|
|
var obj = new GameObject("Test");
|
2024-10-12 15:39:02 +08:00
|
|
|
|
var cacheId = AudioManager.Instance.PlayAudio("Sound_armoredcar_moveloop", AudioCriManager.EPlayType.Sound, obj, true);
|
2024-10-12 15:32:21 +08:00
|
|
|
|
await UniTask.WaitForSeconds(2);
|
|
|
|
|
|
AudioManager.Instance.StopByID(cacheId);
|
|
|
|
|
|
var cacheId2 = AudioManager.Instance.PlayAudio(audioName, AudioCriManager.EPlayType.Sound, obj);
|
|
|
|
|
|
|
|
|
|
|
|
DebugUtil.LogError("cacheId:" + cacheId + " cacheId2:" + cacheId2);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-08 16:47:36 +08:00
|
|
|
|
[Category("音频")]
|
|
|
|
|
|
[DisplayName("停止背景音乐")]
|
|
|
|
|
|
public void StopBGM()
|
|
|
|
|
|
{
|
|
|
|
|
|
AudioManager.Instance.AudioMgrObj.StopBGM();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Category("音频")]
|
|
|
|
|
|
[DisplayName("停止所有音频播放")]
|
|
|
|
|
|
public void StopAll()
|
|
|
|
|
|
{
|
|
|
|
|
|
AudioManager.Instance.AudioMgrObj.StopAll();
|
|
|
|
|
|
}
|
2024-08-06 13:40:53 +08:00
|
|
|
|
|
2024-09-10 14:56:42 +08:00
|
|
|
|
[Category("音频")]
|
|
|
|
|
|
[DisplayName("播放BGM")]
|
|
|
|
|
|
public void PlayBGM()
|
|
|
|
|
|
{
|
|
|
|
|
|
//AudioManager.Instance.StopAll();
|
2024-10-10 18:55:19 +08:00
|
|
|
|
AudioManager.Instance.PlayAudio("ui_common_back", AudioCriManager.EPlayType.Sound, null, true);
|
2024-09-10 14:56:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Category("音频")]
|
|
|
|
|
|
[DisplayName("播放BGM Fader")]
|
|
|
|
|
|
public void PlayBGMFader()
|
|
|
|
|
|
{
|
|
|
|
|
|
//AudioManager.Instance.StopAll();
|
|
|
|
|
|
AudioManager.Instance.PlayAudio("bgm_19", AudioCriManager.EPlayType.Music, null, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-06 13:40:53 +08:00
|
|
|
|
[Category("音频")]
|
|
|
|
|
|
[DisplayName("多个音频同时播放")]
|
|
|
|
|
|
public async void PlayMany()
|
|
|
|
|
|
{
|
2024-08-08 12:19:32 +08:00
|
|
|
|
List<AudioInst> audios = new();
|
|
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var audio = AudioManager.Instance.GetStoryAudioInst();
|
|
|
|
|
|
audios.Add(audio);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await UniTask.Delay(1000);
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var audio = audios[1];
|
|
|
|
|
|
//audio.Stop();
|
|
|
|
|
|
await UniTask.DelayFrame(2);
|
|
|
|
|
|
audio.Play("CueSheet_Sound", "Sound_Shoot_3_1");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await UniTask.Delay(1000);
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var audio = audios[2];
|
|
|
|
|
|
//audio.Stop();
|
|
|
|
|
|
await UniTask.DelayFrame(2);
|
|
|
|
|
|
audio.Play("CueSheet_Sound", "Sound_Shoot_3_1");
|
|
|
|
|
|
}
|
2024-08-06 13:40:53 +08:00
|
|
|
|
|
2024-08-08 12:19:32 +08:00
|
|
|
|
await UniTask.Delay(1000);
|
|
|
|
|
|
AudioManager.Instance.ReleaseStoryAudios();
|
2024-08-06 13:40:53 +08:00
|
|
|
|
}
|
2024-07-08 15:28:18 +08:00
|
|
|
|
}
|