【Unity】The way to fix error CS0619:’GUIText’ is obsolete:’GUIText has been removed. Use UI.Text instead.’



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.


Unity 2019.4.3f1


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.

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.




Your email address will not be published. Required fields are marked *


How to fix AnimationEvent ‘Hit’ on animation ‘Attack1’ has no receiver! in Unity

Contents1 Overview2 Environments3 When error happened4 How to fix4.1 Copy the Animation4.2 Deleting ‘Hit’ Event4.3 Test Overview When we got free Animation at Unity Asset Store and used it with SimpleAnimation, I encountered following error. AnimationEvent ‘Hit’ on animation ‘Attack1’ has no receiver! Are you missing a component? To come to the point, the error could be fixed by deleting Animation Event from the Inspector. The following shows how to fix it step by step. Environments Windows10Unity 2020.1.f1 When error happened We used two packages, Robot Kyle from the Unity Technologies and WARRIOR PACK BUNDLE 3 FREE Animation from Explosive …

【Unity】Object starts to chase the player approaching

Contents1 Overview2 Environment3 Picture of implementation4 Step1 : Set the player5 Step:2 Cube Object chasing player6 Step : 3 Script7 Step : 4 Test Overview There is a sample the Cube Object starts to chase the player who goes in a certain area around it. Environment Unity 2020 1.1f1Windows10 Picture of implementation Step1 : Set the player Ethan from the Standard Assets can be used as a human object. Flowwing article explains how to set Ethan and move him. 【Unity】Standard Assetsでサクッと人間をキー操作する After place Ethan on Terrian, set the Tag in inspector “Player”. Adding rigidbody and capusule collider is needed. Step:2 …

Language Switcher