Код:
Синтаксис:
Используется csharp
void Start()
{
sensivity = StaticLoaderSettings.sensivity;
audioSource = GetComponent<AudioSource> ();
if (UseMicrophone)
{
if (Microphone.devices.Length > 0)
{
SelectedDevice = Microphone.devices[0].ToString();
audioSource.clip = Microphone.Start(SelectedDevice, true, 2, 44100);
}
else
{
UseMicrophone = false;
}
}
else
{
audioSource.clip = audioClip;
}
audioSource.Play();
}
private void Update()
{
loundless = getVolume() * sensivity;
}
float getVolume()
{
float[] data = new float[128];
float a = 0;
audioSource.GetOutputData(data, 0);
foreach (float s in data)
{
a += Mathf.Abs(s);
}
return a / 128;
}
{
sensivity = StaticLoaderSettings.sensivity;
audioSource = GetComponent<AudioSource> ();
if (UseMicrophone)
{
if (Microphone.devices.Length > 0)
{
SelectedDevice = Microphone.devices[0].ToString();
audioSource.clip = Microphone.Start(SelectedDevice, true, 2, 44100);
}
else
{
UseMicrophone = false;
}
}
else
{
audioSource.clip = audioClip;
}
audioSource.Play();
}
private void Update()
{
loundless = getVolume() * sensivity;
}
float getVolume()
{
float[] data = new float[128];
float a = 0;
audioSource.GetOutputData(data, 0);
foreach (float s in data)
{
a += Mathf.Abs(s);
}
return a / 128;
}