Skip to content

Instantly share code, notes, and snippets.

@curious-username
Last active April 27, 2022 02:26
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 curious-username/1f9c1985b0346feae2dc25bde2164c03 to your computer and use it in GitHub Desktop.
Save curious-username/1f9c1985b0346feae2dc25bde2164c03 to your computer and use it in GitHub Desktop.
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