LoginSignup
3
2

More than 5 years have passed since last update.

AudioSourceをアタッチせずに音を再生する【Unity】

Last updated at Posted at 2015-07-25

AudioSource.PlayClipAtPoint()を使用して、AudioSourceをアタッチせずに音を鳴らします。

private AudioClip clip;

void Start () {
    clip = Resources.Load ("se") as AudioClip;
}

void Update () {
    if (Input.GetButtonDown ("Fire1")) {
        AudioSource.PlayClipAtPoint(clip, Vector3.zero);
    }
}

この方法だと、"One shot audio"というGameObjectができて、再生が終了すると消えます。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2