オーディオリスナーが2つあるという警告を回避する方法

音の発生位置を0に設定する。
using UnityEngine;
using System.Collections;
public class Cureitem : MonoBehaviour {
private GameObject tank;
public int reward;
public AudioClip cureItemGet;
public GameObject effectPrefab;
void OnTriggerEnter(Collider other){
if(other.gameObject.CompareTag("Player")){
tank = GameObject.Find("Tank");
//Debug.Log(tank);
TankHealth th = tank.GetComponent<TankHealth>();
th.AddHP(reward);
Destroy(gameObject);
// (ポイント)音の発生位置を(0,0,0)に設定する。
AudioSource.PlayClipAtPoint(cureItemGet, Vector3.zero);
GameObject effect = Instantiate(effectPrefab, transform.position, Quaternion.identity) as GameObject;
Destroy(effect, 1.0f);
}
}
}
Unity Code Memo
他のコースを見る
音の発生位置を0に設定する。
using UnityEngine;
using System.Collections;
public class Cureitem : MonoBehaviour {
private GameObject tank;
public int reward;
public AudioClip cureItemGet;
public GameObject effectPrefab;
void OnTriggerEnter(Collider other){
if(other.gameObject.CompareTag("Player")){
tank = GameObject.Find("Tank");
//Debug.Log(tank);
TankHealth th = tank.GetComponent<TankHealth>();
th.AddHP(reward);
Destroy(gameObject);
// (ポイント)音の発生位置を(0,0,0)に設定する。
AudioSource.PlayClipAtPoint(cureItemGet, Vector3.zero);
GameObject effect = Instantiate(effectPrefab, transform.position, Quaternion.identity) as GameObject;
Destroy(effect, 1.0f);
}
}
}
オーディオリスナーが2つあるという警告を回避する方法