Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
unityで3つ以上のカメラを切りかえる
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class kameraswich : MonoBehaviour {
public List<GameObject> cameras = new List<GameObject>();
private int nowCameraNo;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown("space"))
{
int nextCameraNo = nowCameraNo + 1;
if (nextCameraNo >= cameras.Count) nextCameraNo = 0;
cameras[nowCameraNo].SetActive(false);
cameras[nextCameraNo].SetActive(true);
Debug.Log(nowCameraNo);
nowCameraNo = nextCameraNo;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment