Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bibinba
Created March 18, 2018 05:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bibinba/7e651ee0333ffd93fff1c6d646e4b06c to your computer and use it in GitHub Desktop.
Save bibinba/7e651ee0333ffd93fff1c6d646e4b06c to your computer and use it in GitHub Desktop.
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