Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kaoru-fukusato/ade1f24a5ab61b3adaa3b56b1302ed69 to your computer and use it in GitHub Desktop.
Save kaoru-fukusato/ade1f24a5ab61b3adaa3b56b1302ed69 to your computer and use it in GitHub Desktop.
スクリプト AudioPlayer コンポーネントの設定
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class audioclip : MonoBehaviour
{
public AudioClip audioClip1;
public AudioClip audioClip2;
public AudioClip audioClip3;
public AudioClip audioClip4;
public AudioClip audioClip5;
private AudioSource audioSource;
//
void Start()
{
audioSource = gameObject.GetComponent<AudioSource>();
}
// Update is called once per frame
void Update()
{
//Z
if (Input.GetKeyDown(KeyCode.Z)) audioSource.PlayOneShot(audioClip1);
//X
if (Input.GetKeyDown(KeyCode.X)) audioSource.PlayOneShot(audioClip2);
//C
if (Input.GetKeyDown(KeyCode.C)) audioSource.PlayOneShot(audioClip3);
//V
if (Input.GetKeyDown(KeyCode.V)) audioSource.PlayOneShot(audioClip4);
//B
if (Input.GetKeyDown(KeyCode.B)) audioSource.PlayOneShot(audioClip5);
//F Stop
if (Input.GetKeyDown(KeyCode.F)) audioSource.Stop();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment