Last active
April 27, 2022 02:26
-
-
Save curious-username/1f9c1985b0346feae2dc25bde2164c03 to your computer and use it in GitHub Desktop.
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; | |
using Cinemachine; | |
public class CameraSwap : MonoBehaviour | |
{ | |
[SerializeField] | |
private CinemachineVirtualCamera[] cinemachineVirtualCameras; | |
private int _count = 0; | |
void Update() | |
{ | |
if (Input.GetKeyDown(KeyCode.C)) | |
{ | |
if(_count < cinemachineVirtualCameras.Length ) | |
{ | |
cinemachineVirtualCameras[_count].enabled = true; | |
_count++; | |
} | |
else | |
{ | |
foreach(CinemachineVirtualCamera camera in cinemachineVirtualCameras) | |
{ | |
camera.enabled = false; | |
} | |
_count = 0; | |
cinemachineVirtualCameras[_count].enabled = true; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment