using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
|
public class VoiceWarehouse
|
{
|
static int instanceId = 1000;
|
static Dictionary<int, AudioClip> audioClips = new Dictionary<int, AudioClip>();
|
static Dictionary<int, byte[]> audioVoices = new Dictionary<int, byte[]>();
|
|
public static event Action<int> voiceRecoderEvent;
|
|
public static int SaveVoice(AudioClip _clip)
|
{
|
instanceId++;
|
audioClips[instanceId] = _clip;
|
|
return instanceId;
|
}
|
|
public static bool TryGetVoice(int _instanceId, out AudioClip _clip)
|
{
|
return audioClips.TryGetValue(_instanceId, out _clip);
|
}
|
|
public static void SaveVoice(int _instanceId, byte[] _data)
|
{
|
audioVoices.Add(_instanceId, _data);
|
if (voiceRecoderEvent != null)
|
{
|
voiceRecoderEvent(_instanceId);
|
}
|
}
|
|
public static bool TryGetVoice(int _instanceId, out byte[] _data)
|
{
|
return audioVoices.TryGetValue(_instanceId, out _data);
|
}
|
|
public static void Clear()
|
{
|
instanceId = 1000;
|
audioClips.Clear();
|
audioVoices.Clear();
|
}
|
|
}
|