本文整理汇总了C#中SoundType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SoundType.ToString方法的具体用法?C# SoundType.ToString怎么用?C# SoundType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoundType
的用法示例。
在下文中一共展示了SoundType.ToString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SoundFormat
/// <summary>
/// Initializes new instance of SoundFormat class
/// </summary>
/// <param name="soundType"></param>
/// <param name="rate"></param>
/// <param name="channels"></param>
public SoundFormat(SoundType soundType, int rate, int channels)
{
SoundType = soundType;
Format = soundType.ToString();
Rate = rate;
Channels = channels;
Init();
BlockSize = BitsPerSample / 8 * Channels;
UseCustomAudioRendering = true;
}
示例2: Trigger
public void Trigger (SoundType type)
{
List<AudioClip> audioList = new List<AudioClip>();
string soundType = type.ToString();
foreach(AudioClip g in Resources.LoadAll("Sounds/"+soundType, typeof(AudioClip)))
{
audioList.Add(g);
}
// Debug.Log ("SoundManager.cs : Play sound " + soundType);
AudioSource audioSource = Camera.main.GetComponent<AudioSource>();
audioSource.clip = audioList[Random.Range(0, audioList.Count)];
audioSource.Play();
}
示例3: IsPaused
public bool IsPaused(SoundType st)
{
if (st == SoundType.None)
{
return false;
}
if (!sources.ContainsKey(st))
{
sources.Add(st, transform.FindChild(st.ToString()).GetComponent<AudioSource>());
}
AudioSource sound = sources[st];
if (sound.isPlaying)
{
return false;
}
if (sound.time <= 0.1f || sound.time >= sound.clip.length - 0.1f)
{
return false;
}
return true;
}
示例4: IsPlaying
public bool IsPlaying(SoundType st)
{
if (st == SoundType.None)
{
return false;
}
if (!sources.ContainsKey(st))
{
sources.Add(st, transform.FindChild(st.ToString()).GetComponent<AudioSource>());
}
AudioSource sound = sources[st];
return sound.isPlaying;
}
示例5: Stop
public void Stop(SoundType st)
{
if (st == SoundType.None)
{
return;
}
if (!sources.ContainsKey(st))
{
sources.Add(st, transform.FindChild(st.ToString()).GetComponent<AudioSource>());
}
AudioSource sound = sources[st];
if (sound && sound.clip)
{
sound.Stop();
}
}
示例6: Play
public void Play(SoundType st, float delay = 0)
{
if (st == SoundType.None)
{
return;
}
if (!sources.ContainsKey(st))
{
sources.Add(st, transform.FindChild(st.ToString()).GetComponent<AudioSource>());
}
AudioSource sound = sources[st];
if (sound && sound.clip)
{
if (delay > 0)
{
sound.PlayDelayed(delay);
}
else
{
sound.Play();
}
}
else
{
if (audioLoading)
{
AudioLoading al = (Instantiate(audioLoading) as GameObject).transform.GetComponent<AudioLoading>();
al.audioSource = sound;
}
}
}
示例7: PlaySound
internal void PlaySound(SoundType _eSoundType)
{
m_dAudioSources[_eSoundType.ToString()].Stop();
m_dAudioSources[_eSoundType.ToString()].Play();
}
示例8: PlaySound
private void PlaySound(int sound, float spatialBlend, SoundType type, Transform location)
{
if (sound >= soundDB.Length)
{
Debug.Log("ERROR: ID Number is larger than Sound Database! Nothing will be played.");
return;
}
AudioSource source = GetNextAvailableAudioSource();
source.clip = soundDB[sound];
source.spatialBlend = spatialBlend;
//Assign Audiomixer that audiosource points to
switch (type)
{
case SoundType._2dSound:
source.outputAudioMixerGroup = SoundChannel("GameWorld");
break;
case SoundType._3dSound:
source.outputAudioMixerGroup = SoundChannel("GameWorld");
break;
case SoundType._UISound:
source.outputAudioMixerGroup = SoundChannel("UI");
break;
case SoundType.noType:
source.outputAudioMixerGroup = SoundChannel("other");
break;
default:
Debug.Log("SoundMaster.PlaySound doesn't have SoundType" + type.ToString() + " tied to an AudioMixerGroup");
break;
}
source.Play();
if(source.gameObject.name == "BackupSoundPlayer")
{
Destroy(source.gameObject, source.clip.length + 1f);
}
//If there's a SoundPlayer class attached to audiosource's gameobject, have it follow
SoundPlayer supportClass = source.gameObject.GetComponent<SoundPlayer>();
if (supportClass != null)
supportClass.Follow(location);
}