【Unity】The way to fix error CS0619:’GUIText’ is obsolete:’GUIText has been removed. Use UI.Text instead.’
Overview
There occured error CS0619:’GUIText’ is obsolete:’GUIText has been removed. Use UI.Text instead.’ to use Standard Assets. This article shows a way to fix it.
Environment
Unity 2019.4.3f1
Occurences
Making C# script from Assets > Create > C# Script .

Attaching the script to Sphere object by drag & drop, I get message ‘Can’t add script’ .


This massage warns that the name of the script is different from its class name or there are some error of compiling. But I don’t find any error for compiling or the difference of the names.
Now, finding these GUIText error in console tab.

The way to fix it
Double-clicking the error in the console tab then the script “SimpleActivatiorMenu.cs” is opended.
Change it like following.
Addition : using UnityEngine.UI;
Comment out : public GUIText camSwitchButton;
Addition : public Text camSwitchButton;
This is a sample code fixed.
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | using System; using UnityEngine; using UnityEngine.UI; //This is added #pragma warning disable 618 namespace UnityStandardAssets.Utility { public class SimpleActivatorMenu : MonoBehaviour { // An incredibly simple menu which, when given references // to gameobjects in the scene //public GUIText camSwitchButton; //This is comment out public Text camSwitchButton; //This is added public GameObject[] objects; private int m_CurrentActiveObject; private void OnEnable() { // active object starts from first in array m_CurrentActiveObject = 0; camSwitchButton.text = objects[m_CurrentActiveObject].name; } public void NextCamera() { int nextactiveobject = m_CurrentActiveObject + 1 >= objects.Length ? 0 : m_CurrentActiveObject + 1; for ( int i = 0; i < objects.Length; i++) { objects[i].SetActive(i == nextactiveobject); } m_CurrentActiveObject = nextactiveobject; camSwitchButton.text = objects[m_CurrentActiveObject].name; } } } |
After changing codes and save it, the script can be attached to the Sphere Objects.

Please try it if you get the same problem.
This paragraph is genuinely a good one it helps new net people, who are wishing in favor
of blogging.
May I simply say what a comfort to find a person that really knows what they are talking about on the internet.
You actually understand how to bring a problem to light and make it important.
More and more people have to check this out and understand this side of the story.
I can’t believe you aren’t more popular because you most
certainly have the gift.
Hi, I do believe this is a great website. I stumbledupon it
I will come back once again since i have book-marked it.
Money and freedom is the greatest way to change, may you be rich and continue to guide other people.