スクリプトのみ
using System.Collections; using System.Collections.Generic; using UnityEngine; public class destroy_SE : MonoBehaviour { public AudioClip impact;//音のファイル読み込み public AudioClip wallhit; AudioSource audioSource;//音の再生装置 private void Start() { audioSource = GetComponent<AudioSource>(); } //当たって消すパタン private void OnTriggerEnter(Collider other) { if(other.gameObject.tag == "wall")//タグがwallなら { //audioSource.PlayOneShot(wallhit, 0.7F);//impactを音量0.7で再生 } else { Destroy(other.gameObject); audioSource.PlayOneShot(impact, 0.7F);//impactを音量0.7で再生 } //点数を加算 //加算した点数をUIに反映 } //壁 private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "wall")//タグがcollision なら { audioSource.PlayOneShot(wallhit, 0.7F);//wallhitを音量0.7で再生 } } }