2台のカメラのAudioListenerを切り替える
2台のカメラのAudioListenerを切り替える
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour {
public Camera main;
public Camera sub;
// ★2台のカメラのAudioListenerを切り替える(考え方)
public AudioListener mainListener;
public AudioListener subListener;
void Start () {
main.enabled = true;
sub.enabled = false;
mainListener.enabled = true;
subListener.enabled = false;
}
void Update () {
if(Input.GetKey(KeyCode.C)){
main.enabled = false;
sub.enabled = true;
mainListener.enabled = false;
subListener.enabled = true;
} else {
main.enabled = true;
sub.enabled = false;
mainListener.enabled = true;
subListener.enabled = false;
}
}
}
Unity Code Memo
他のコースを見る2台のカメラのAudioListenerを切り替える
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour {
public Camera main;
public Camera sub;
// ★2台のカメラのAudioListenerを切り替える(考え方)
public AudioListener mainListener;
public AudioListener subListener;
void Start () {
main.enabled = true;
sub.enabled = false;
mainListener.enabled = true;
subListener.enabled = false;
}
void Update () {
if(Input.GetKey(KeyCode.C)){
main.enabled = false;
sub.enabled = true;
mainListener.enabled = false;
subListener.enabled = true;
} else {
main.enabled = true;
sub.enabled = false;
mainListener.enabled = true;
subListener.enabled = false;
}
}
}
2台のカメラのAudioListenerを切り替える