Created
May 28, 2020 14:40
-
-
Save fongreecss/4e709eaced74c91888235321c89ce980 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; | |
/** | |
* Vsakemu switcherju oz boxu, ki spreminja pač kamero se doda tag, ki mora biti ime kamere na katero želi preklopit | |
* Vsak switcher mora imet to skripto not. Skripts-> CameraSwitcher | |
* | |
* */ | |
public class CameraSwitcher : MonoBehaviour | |
{ | |
// Start is called before the first frame update | |
private Camera[] cameras = null; | |
private Camera activeCamera = null; | |
void Start() | |
{ | |
this.cameras = Camera.allCameras; | |
} | |
// Update is called once per frame | |
void DisableEveryCamera() | |
{ | |
foreach(Camera cam in Camera.allCameras) | |
{ | |
Debug.Log(cam.name + " is disabled"); | |
cam.enabled = false; | |
} | |
} | |
void Update() | |
{ | |
} | |
private void OnTriggerEnter(Collider coll) | |
{ | |
try | |
{ | |
DisableEveryCamera(); | |
activeCamera = GameObject.Find(this.gameObject.tag).GetComponent<Camera>(); | |
activeCamera.enabled = true; | |
} catch(System.Exception ex) | |
{ | |
Debug.Log(ex.Message); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment