Created
March 18, 2018 05:30
-
-
Save bibinba/7e651ee0333ffd93fff1c6d646e4b06c to your computer and use it in GitHub Desktop.
unityで3つ以上のカメラを切りかえる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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