示例#1
0
    public AudioSource PlayeMusicAudio(MyAudioName ClipName, float _Volume = 1)
    {
        string _ClipName = ClipName.ToString();

        if (this._dicAudio.ContainsKey(_ClipName))
        {
            _Volume *= this._musicVolume;
            if (0.01f < _Volume)
            {
                this._musicSource.loop   = true;
                this._musicSource.clip   = this._dicAudio[_ClipName];
                this._musicSource.volume = _Volume;
                this._musicSource.Play();
            }
            else
            {
                this._musicSource.Stop();
            }
        }
        else
        {
            Debug.LogWarning("找不到对应得声音");
        }
        return(this._musicSource);
    }
示例#2
0
    public AudioSource PlayerEffectAudio(MyAudioName ClipName, float _Volume = 1)
    {
        string _ClipName = ClipName.ToString();

        if (this._dicAudio.ContainsKey(_ClipName))
        {
            _Volume *= this._effectVolume;
            if (0.01f < _Volume)
            {
                this._effectSource.PlayOneShot(this._dicAudio[_ClipName], _Volume);
            }
        }
        else
        {
            Debug.LogWarning("找不到对应得声音");
        }
        return(this._effectSource);
    }