Error CS0619: 'GUIText' is obsolete: 'GUIText has been removed. Use UI.Text instead.' (776250)

I am using a asset on the unity store that was depreciated a couple of years ago. It worked under unity 2019.2 but now gives errors in the console. I get the following error in unity 2019.3
error CS0619: ‘GUIText’ is obsolete: ‘GUIText has been removed. Use UI.Text instead.’

I changed 2 lines of code (see picture) but the other 2 lines stll gives errors.
As it is not my asset, I do not fully understand it. Any help on the conversion would be cool. It’s the equilivant of pixeloffset.

Here is the code:

public static void changeFont(GUIText gt,
                                  Vector2 vec)
    {
        Font newFont = getFont(gt.font.name,vec);
        if(newFont)
        {
            gt.font = newFont;
            gt.material = newFont.material;  
        }
    }
    public static void resizeGUIText(GUIText gt,
                                     Vector2 vec)
    {
        if(gt!=null)
        {
            Vector2 v = gt.pixelOffset;
            v.x *= vec.x;
            v.y *= vec.y;      
            gt.pixelOffset = v;
        }
    }
5 Likes

I’m having the exact same problem. Mine is linked to a script that comes with the Standard Assets package from Unity that I am using for a course. I did the same fix, changing GUIText to UnityEngine.UI.Text, but it greatly altered the alignment of my camera and I’m worried it will cause problems down the road if I leave it that way. Did you find any other fix?

7 Likes

The UI system added in Unity 4.6 which includes UI.Text works fundamentally different than the now removed GUIText. Normally you’d do your resizing in the inspector now instead of everything having to be hard coded in your scripts. Though it is still possible to do in scripts, the old system you had to do everything in scripts. Now usually you don’t.

Setting position and size of a UI.Text now is done via height/width and achor positions relative to its canvas, or just by adjusting the GameObject’s scale, so there is no direct translation of the above code without a lot more context.

https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/index.html

If none of that makes any sense, take the time to follow some UI tutorials. As you’ll need to understand concepts like canvas, anchors, etc, to make any progress, and none of that was in the old UI system.

If you want to continue using code which relies on the old removed UI system, just stick to a version of Unity which supports it. (2018.4.x LTS is probably the best choice?) Otherwise scrap this code and create or otherwise acquire something to do the job using the current system.

On the Standard Assets, there is no updated Standard Assets package updated for 2019.3. Some things will still work, but it was last updated for a version of Unity a couple years old. I’d suggest just removing anything which throws compile errors and not trying to fix them. If they all just needed simple fixes, Unity would just do it themselves.

3 Likes

For the “GUIText”, just change it to “GUI”,
Ex: [RequireComponent(typeof (GUI))] in ForcedReset.cs.
In SimpleActivationMenu.cs, change the type of camSwitchButton to AlphaButtonClickMask. Ex: private AlphaButtonClickMask camSwitchButton;
Use try to use the quickfix function in your visual studio. The code will run with a few warnings.
/PS: I’m new to this. Hope it helps.

5 Likes

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

Can anyone tell how to resolved this error.

3 Likes

See Ryiah’s post here for a fix: Standard Assets 2018 - let us know what you think! page-4#post-5458527

Delete the cams in the code

1 Like

I will Comment whole error Script :rage::rage::rage::rage::smile::smile::smile:

2 Likes

This is what worked for me.
In SimpleActivatorMenu.cs the import using UnityEngine.UI, then change GUI to Text object for
camSwitchButton. That’s it.

All the best.

47 Likes

problem fixed here :

20 Likes

thank you so much

And what about DebugGui.GetComponent().HitTest?
Where are the conversions for the dot functions?

1 Like

solved here :

3 Likes

I can’t believe they just changed something that renders so many assets worthless

1 Like

Hi, i’m try all. But not work for me. Help me

Change GUIText to GUI
Delete the two lines of code that write text with a squiggly line
and it will run

Im on 2023.16f1 using HFPS kit . i got this bug.

1 Like

here is the solution:
1)in first line, write Using UnityEngine.UI
2)instead of GUItext write Text(t should be capital)

6 Likes

F

fixed thank u,

1 Like

Thank you very mutch

2 Likes