コード例 #1
0
    public void DoSound(ClipSet _clone, string _cloneName)
    {
        if (_clone._clip == null)
        {
            return;
        }
        GameObject  NewAudio     = new GameObject();
        AudioSource _cloneSource = NewAudio.AddComponent <AudioSource>();

        NewAudio.transform.SetParent(SoundEffectPool, false);
        NewAudio.transform.name = _cloneName == null ? _clone._clip.name : _cloneName;
        NewAudio.SetActive(NewAudio);

        _cloneSource.outputAudioMixerGroup = SoundEffectOutput;
        _cloneSource.clip        = _clone._clip;
        _cloneSource.mute        = _clone.Mute;
        _cloneSource.playOnAwake = _clone.PlayOnAwake;
        _cloneSource.loop        = _clone.Loop;
        _cloneSource.priority    = _clone.Priority;
        _cloneSource.volume      = _clone.Volume;
        _cloneSource.pitch       = _clone.Pitch;
        _cloneSource.Play();
        if (!_clone.Loop && NewAudio != null)
        {
            _Clear = DoClear;
            _Clear.Invoke(NewAudio, _cloneSource.clip.length);
        }
    }
コード例 #2
0
    void PlayClipAtPointFromClipSetInPosition(ClipSet x)
    {
        AudioSource newAudioSource = new GameObject("DeathAudioSource", typeof(AudioSource)).GetComponent <AudioSource>();
        AudioClip   clip           = x.GetRandomClip().AudioClip;

        newAudioSource.clip = clip;
        newAudioSource.outputAudioMixerGroup = audioMixer;
        newAudioSource.Play();
        Destroy(newAudioSource.gameObject, clip.length);
    }
コード例 #3
0
ファイル: SoundChannel.cs プロジェクト: ruslan-smirnov/Thirty
    public bool PlayManagedClip(object key, Transform parent, ClipSet clip, SoundManager.SoundType type, int priority = 0, float volume = 1, float updateDeltaTime = 0.5f)
    {
        bool res = true;
        var  src = GetManagedSource(key, parent);

        if (src.source != null)
        {
            src.clipQueue = new Queue <ClipSet>();
            src.clipQueue.Enqueue(clip);
            src.coroutineClipQueue = StartCoroutine(PlayClipsQueue(src, false, volume, type, updateDeltaTime));
        }
        else
        {
            if (usedSources.Count > 0 && usedSources.Any(s => s.priority < priority))
            {
                var prirsrc = usedSources.Where(s => s.priority < priority).OrderBy(s => s.priority).First();
                ReturnBackSource(prirsrc);
                src           = GetManagedSource(key, parent);
                src.clipQueue = new Queue <ClipSet>();
                src.clipQueue.Enqueue(clip);
                src.coroutineClipQueue = StartCoroutine(PlayClipsQueue(src, false, volume, type));
                Debug.Log("Был заменен источник звука с боле низким приоритетом");
            }
            else if (managedUsedSources.Count > 0 && managedUsedSources.Any(s => s.Value.Any(ss => ss.priority < priority)))
            {
                var prirsrc = managedUsedSources.Where(s => s.Value.Any(ss => ss.priority < priority))
                              .SelectMany(s => s.Value.Where(ss => ss.priority < priority))
                              .OrderBy(s => s.priority)
                              .First();
                ReturnBackSource(prirsrc);
                src           = GetManagedSource(key, parent);
                src.clipQueue = new Queue <ClipSet>();
                src.clipQueue.Enqueue(clip);
                src.coroutineClipQueue = StartCoroutine(PlayClipsQueue(src, false, volume, type));
                Debug.Log("Был заменен источник звука с боле низким приоритетом");
            }
            else
            {
                Debug.Log("В пуле нет доступного сурса");
                res = false;
            }
        }

        return(res);
    }
コード例 #4
0
 //自訂義要的音效
 public void CustomizeSound(ClipSet cilp, string name)
 {
     _AddSound = DoSound;
     _AddSound.Invoke(cilp, name);
 }
コード例 #5
0
    void PlayFromClipSet(ClipSet clipset)
    {
        Clip x = clipset.GetRandomClip();

        audioSource.PlayOneShot(x.AudioClip, x.volume);
    }
コード例 #6
0
 public CommandHandler()
 {
     ClipSet = new ClipSet();
 }