Trocar de cameras

using UnityEngine;
using System.Collections;

public class CamerasScript : MonoBehaviour {
    public Camera[] cam;
    public int NumeroMax;
    public int numeroCam;
    // Use this for initialization
    void Start () {
        NumeroMax= cam.Length;
        numeroCam = 1;
        foreach (Camera obj in cam) {
            obj.gameObject.SetActive (false);
        }
        cam[numeroCam - 1].gameObject.SetActive (true);
    }
    
    // Update is called once per frame
    void Update () {
//        contador++;
//        if(contador==100f){
//            
//        }
        if(Input.GetKeyDown ("c") && numeroCam < NumeroMax){
            numeroCam++;
            foreach (Camera obj in cam) {
                obj.gameObject.SetActive (false);
            }
            cam[numeroCam- 1].gameObject.SetActive (true);
        }
        if(Input.GetKeyDown ("c") && numeroCam== NumeroMax){
            
            foreach (Camera obj in cam) {
                obj.gameObject.SetActive (false);
            }
            cam[numeroCam- 1].gameObject.SetActive (true);
            numeroCam= 0;
        }

    }
}

Comentários

Postagens mais visitadas