You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
768 B
42 lines
768 B
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
|
|
/// <summary> |
|
/// 表示一个提示音。 |
|
/// </summary> |
|
public class PromptTone : MonoBehaviour |
|
{ |
|
private static float[] data; |
|
|
|
/// <summary> |
|
/// 提示音的波行数据。 |
|
/// </summary> |
|
public static float[] Data |
|
{ |
|
get |
|
{ |
|
if (data == null) |
|
Initialize(); |
|
|
|
return data; |
|
} |
|
} |
|
|
|
void Awake() |
|
{ |
|
if (data == null) |
|
Initialize(); |
|
} |
|
|
|
private static void Initialize() |
|
{ |
|
var clip = Resources.Load<AudioClip>("Audios/Voice/PromptTone"); |
|
|
|
data = new float[clip.samples]; |
|
|
|
clip.GetData(Data, 0); |
|
|
|
Resources.UnloadAsset(clip); |
|
} |
|
} |