GabeV
GabeV

Reputation: 11

GUIText replacement?

Alright so I'm learning unity right now and I opened my game this morning and ran into this error code

Assets\Standard Assets\Utility\SimpleActivatorMenu.cs(11,16): error CS0619: 
'GUIText' is obsolete: 'GUIText has been removed. Use UI.Text instead.' 

I have tried replacing GUIText with UI.Text however that lead to a different error messages of:

Assets\Standard Assets\Utility\SimpleActivatorMenu.cs(11,16): error CS0246:
The type or namespace name 'UI' could not be found (are you missing a using
directive or an assembly reference?)

or

Assets\Standard Assets\Utility\SimpleActivatorMenu.cs(11,16): error CS0246:
The type or namespace name 'UIText' could not be found (are you missing a using
directive or an assembly reference?)

Can anybody help me out here?

Upvotes: 1

Views: 3065

Answers (5)

Hamed Mohamadi
Hamed Mohamadi

Reputation: 20

Don't forget to change your Library to the following:

Using UnityEngine.UI;

instead of

Using UnityEngine;

I'm new to Unity. And I hope it works.

Upvotes: 0

Abhijeet Kudche
Abhijeet Kudche

Reputation: 3

Add this line :

using UnityEngine.UI;

and then replace :

GUIText with Text

Upvotes: 0

Emre Gürses
Emre Gürses

Reputation: 2180

You should fallow these steps

  1. adding "using UnityEngine.UI;" begining of .cs file
  2. change all GUIText to Text.

Upvotes: 0

Jovani
Jovani

Reputation: 11

you can just replace it using Text from UnityEngine.UI

Here's an example:

using UnityEngine.UI;

namespace YourNameSpace.Utility
{
    public class YourClass : MonoBehaviour
    {
        public Text myText;

        void Start()
        {
          myText.text = "Your text here";
        }

    }
}

Upvotes: 1

Kale_Surfer_Dude
Kale_Surfer_Dude

Reputation: 914

You cannot simply replace GUIText with Text unfortunately. Check this answer out:

GUIText is deprecated, so what should I use instead of it?

Upvotes: 1

Related Questions