Created
August 11, 2024 19:31
-
-
Save kaoru-fukusato/ade1f24a5ab61b3adaa3b56b1302ed69 to your computer and use it in GitHub Desktop.
スクリプト AudioPlayer コンポーネントの設定
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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