2025-03-06 17:24:31 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
2025-03-07 17:52:50 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Audio<69><6F><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public struct AudioData
|
2025-03-06 17:24:31 +08:00
|
|
|
|
{
|
2025-03-07 17:52:50 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20>ӳٲ<D3B3><D9B2><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float delayTime;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20><>Ƶ
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public AudioClip clip;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float volume;
|
2025-03-06 17:24:31 +08:00
|
|
|
|
|
2025-03-07 17:52:50 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20>ص<EFBFBD><D8B5><EFBFBD>Ϊ
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public System.Action onComplete;
|
2025-03-06 17:24:31 +08:00
|
|
|
|
|
2025-03-07 17:52:50 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20>ӳٻص<D9BB>ִ<EFBFBD>е<EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float delayOnCompleteTime;
|
2025-03-06 17:24:31 +08:00
|
|
|
|
|
2025-03-07 17:52:50 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20><>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float fadeDuration;
|
2025-03-06 17:24:31 +08:00
|
|
|
|
|
2025-03-07 17:52:50 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20>Ƿ<C7B7><F1B2BBB4><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ζԻ<CEB6>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool isNotOverVoice;
|
2025-03-06 17:24:31 +08:00
|
|
|
|
|
2025-03-07 17:52:50 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20>Ƿ<EFBFBD><C7B7><EFBFBD>3D<33><44><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool is3D;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 3D<33><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public GameObject soundObject;
|
2025-03-06 17:24:31 +08:00
|
|
|
|
}
|
2025-03-07 17:52:50 +08:00
|
|
|
|
|
|
|
|
|
|
public interface IAudio
|
2025-03-06 17:24:31 +08:00
|
|
|
|
{
|
2025-03-07 17:52:50 +08:00
|
|
|
|
void Play(AudioData audioData);
|
2025-03-06 17:24:31 +08:00
|
|
|
|
|
2025-03-07 17:52:50 +08:00
|
|
|
|
void Stop(AudioData audioData);
|
2025-03-06 17:24:31 +08:00
|
|
|
|
|
2025-03-07 17:52:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
public abstract class AbstractAudio : IAudio
|
|
|
|
|
|
{
|
|
|
|
|
|
public abstract void Play(AudioData audioData);
|
2025-03-06 17:24:31 +08:00
|
|
|
|
|
2025-03-07 17:52:50 +08:00
|
|
|
|
public abstract void Stop(AudioData audioData);
|
2025-03-06 17:24:31 +08:00
|
|
|
|
|
2025-03-07 17:52:50 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20><>Ƶ<EFBFBD><C6B5><EFBFBD>ݳ<EFBFBD>ʼ<EFBFBD><CABC>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="audioData"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public virtual AudioData AudioDataInitialize(AudioData audioData)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(audioData.volume == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
audioData.volume = 1f;
|
|
|
|
|
|
}
|
|
|
|
|
|
return audioData;
|
|
|
|
|
|
}
|
2025-03-06 17:24:31 +08:00
|
|
|
|
}
|