The same idea like the message: "Display 1 No cameras rendering" I'm trying to do it too but i don't see anything when running the game.

In the Hierarchy i have a empty GameObject and in the Inspector attached to it the script and two components: GUI Text and GUI Texture

This is the script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class SwitchCameras : MonoBehaviour
    [Header("Cameras Init")]
    public Camera[] cameras;
    public Vector3[] originalPosition;
    public Vector3 currentCameraOriginalPosition, currentCameraPosition;


    [Header("Cameras Switch")]
    public string currentCameraName;
    public Vector3[] lastCameraPosition;

    private int currentCamera = 0;


    [Header("Gui Text")]
    public GUIText myGUItext;
    public GUITexture texture;
    public int guiTime = 2;

    void Start()
        cameras = Camera.allCameras;
        lastCameraPosition = new Vector3[cameras.Length];

        if (cameras.Length >= 1)
            originalPosition = new Vector3[cameras.Length];
            for (int i = 0; i < cameras.Length; i++)
                originalPosition[i] = cameras[i].transform.position;

        if (cameras.Length == 1)
            myGUItext.text = "Need more then 1 camera for switching..";
            Debug.Log("Found " + cameras.Length + " cameras");

        for (int i = 0; i < cameras.Length; i++)
            cameras[i].enabled = false;
        cameras[0].enabled = true;
        currentCameraName = cameras[0].name;
        currentCameraOriginalPosition = originalPosition[0];

    void LateUpdate()
        if (Input.GetKeyDown(KeyCode.C))
            cameras[currentCamera].enabled = false;

            if (++currentCamera == cameras.Length)
                currentCamera = 0;

            cameras[currentCamera].enabled = true;
            currentCameraName = cameras[currentCamera].name;

            currentCameraOriginalPosition = originalPosition[currentCamera];
        lastCameraPosition[currentCamera] = cameras[currentCamera].transform.position;
        currentCameraPosition = lastCameraPosition[currentCamera];

    IEnumerator GuiDisplayTimer()
        yield return new WaitForSeconds(guiTime);

I used a break point and it's getting to the line:

myGUItext.text = "Need more then 1 camera for switching..";

But not showing it on the game view when running the game.

  • 2
    \$\begingroup\$ instead of using the old GUI components why not use the new UI system. Set up your text in a panel in the canvas and activate that panel? \$\endgroup\$ – Uri Popov Oct 30 '17 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.