Unity2019_音效系统

音频源和音频监听组件

 添加音频组件,并指定要播放的音频

添加声音接受组件

音频组件参数

 空间混合Spatial Blend是设置3D声音影响强度的,为1的时候3D效果比较强度比较大。

音频组件常用的函数

 

public class Test : MonoBehaviour
{
    // Start is called before the first frame update
    AudioSource audio;
    void Start()
    {
        audio = transform.GetComponent<AudioSource>();
        audio.clip = Resources.Load<AudioClip>("bj4");
    }

    // Update is called once per frame
    void Update()
    {
		if (Input.GetKeyDown("a"))
		{
            if(audio.isPlaying == false)
			{
                audio.Play();
            }
		}
		if (Input.GetKeyDown("b"))
		{
            audio.Pause();
		}
    }
}

音频过滤器和音频混响区的区别

猜你喜欢

转载自blog.csdn.net/qq_35647121/article/details/126573409