# How can i display a nice big gui text in the middle of game view screen?

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
{
public Camera[] cameras;
public Vector3[] originalPosition;
[HideInInspector]
public Vector3 currentCameraOriginalPosition, currentCameraPosition;

[Space(5)]

public string currentCameraName;
public Vector3[] lastCameraPosition;

private int currentCamera = 0;

[Space(5)]

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..";
myGUItext.gameObject.SetActive(true);
texture.gameObject.SetActive(true);
StartCoroutine(GuiDisplayTimer());
}
else
{
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);
myGUItext.gameObject.SetActive(false);
texture.gameObject.SetActive(false);
}
}


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.

• 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? – Uri Popov Oct 30 '17 at 10:01