Created
November 23, 2019 06:52
-
-
Save IshidaGames/257f2d6676a7b3078e35438dbc79188f to your computer and use it in GitHub Desktop.
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; | |
//オブジェクトにAudioSourceコンポーネントを追加 | |
[RequireComponent(typeof(AudioSource))] | |
public class SE : MonoBehaviour | |
{ | |
//音声ファイルを入れる | |
public AudioClip[] sound; | |
//AudioSourceコンポーネントを入れる変数 | |
AudioSource audioSource; | |
void Start() | |
{ | |
//AudioSourceコンポーネントを取得 | |
audioSource = GetComponent<AudioSource>(); | |
} | |
public void AttackSound() | |
{ | |
//音声を鳴らす | |
audioSource.PlayOneShot(sound[0]); | |
} | |
public void DamageSound() | |
{ | |
audioSource.PlayOneShot(sound[1]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment