Unity 2019.2.21 to 2021.1 error. Need help upgrading

I have an old project that partly was done from someone else. It was last done on 2019.2.21. Now when I open it with unity 2021.1 it gives some errors. If someone could help on the translation that would be cool. I f needed, I can message you with the full scripts. Unity doesn’t like it when people post like that. The lines with errors say //error.

////
/////////////////////////////////////
public class Joystick : MonoBehaviour {
private GUITexture gui;                // Joystick graphic (ERROR)


///////////////////////////////////////////
void Start()
    {
        // Cache this component at startup instead of looking up every frame  
        gui = GetComponent<GUITexture>(); //(ERROR)

        defaultRect = gui.pixelInset;    //(ERROR)

        defaultRect.x += transform.position.x * Screen.width;// + gui.pixelInset.x; // -  Screen.width * 0.5;
        defaultRect.y += transform.position.y * Screen.height;// - Screen.height * 0.5;

        transform.position = Vector3.zero;
//        transform.position.x = 0.0f;
     //   transform.position.y = 0.0f;
          

////////////////////////////////////////////////////
        if ( touchPad )
        {
            // If a texture has been assigned, then use the rect from the gui as our touchZone
            if ( gui.texture )  //ERROR
                touchZone = defaultRect;
        }
        else

////////////////////////////////////
void setColor(float r)
    {
        Color c = gui.color;  //ERROR
      
        c.a=r;
        //c.g=g;
        //c.b=b;
        if(gui.color!=c) //ERROR
        {
            gui.color=c;    //ERROR
        }  
    }

///////////////////////////////////
void ResetJoystick()
    {
        // Release the finger control and set the joystick back to the default position
        gui.pixelInset = defaultRect;  //ERROR

//////////////////////////////////////////////
void OnMouseOver()
    {
        if(m_on)
        {
            Color tmp = gui.color;  //ERROR
            tmp.a = 0.35f;
            gui.color = tmp;  //ERROR
        }
                      
    }
///////////////////////////////////////////////////////
    void OnMouseExit()
    {
        if(m_on)
        {
            Color tmp = gui.color;  //ERROR
            tmp.a = 0.25f;
            gui.color = tmp; //ERROR
        }
    }
/////////////////////////////////////////////////////
if ( touchPad )
                {              
                    if ( touchZone.Contains( touch.position ) )
                        shouldLatchFinger = true;
                }
                else if ( gui.HitTest( touch.position ) )  //ERROR
                {
                    shouldLatchFinger = true;
                }

//////////////////////////////////

else
                    {                  
                        // Change the location of the joystick graphic to match where the touch is
                        Vector2 gmin = guiBoundary.min;
                        Vector2 gmax = guiBoundary.max;
                        Rect tmpRect = gui.pixelInset;  //ERROR
                      
                        tmpRect.x = Mathf.Clamp( guiTouchPos.x, gmin.x, gmax.x );
                        tmpRect.y = Mathf.Clamp( guiTouchPos.y, gmin.y, gmax.y );      
                        gui.pixelInset = tmpRect;  //ERROR
                    }
////////////////////////////
if ( !touchPad )
        {
            // Get a value between -1 and 1 based on the joystick graphic location
            position.x = ( gui.pixelInset.x + guiTouchOffset.x - guiCenter.x ) / guiTouchOffset.x;  //ERROR
            position.y = ( gui.pixelInset.y + guiTouchOffset.y - guiCenter.y ) / guiTouchOffset.y;  //ERROR
        }
///////////////////////////////////

It might be that under the new Unity you need to install a package for the old GUI system (like GUITexture)… that would be one place to check first. Here is some more reading:

Remember: NOBODY memorizes error codes. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.

The important parts of an error message are:

  • the description of the error itself (google this; you are NEVER the first one!)
  • the file it occurred in (critical!)
  • the line number and character position (the two numbers in parentheses)

All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don’t have to stop your progress and fiddle around with the forum.

How to understand compiler and other errors and even fix them yourself:

Try look at where each error is. Have you noticed a pattern where each error is? Look into it with more detail

“Try look at where each error is.”
CS0619. The issue is the GUItext, GUItexture and all of that was depreciated to the new system. I was wondering if someone had the conversion.

“Unity you need to install a package for the old GUI system”
Where would this be and what would it be called? I looked under the packages and do not see this.

Here’s 1 example. The gt.pixeloffset gives an error. So the conversion to just “gt” doesn’t work. Text obviously is not the proper thing

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;
        }
    }
public static void resizeGUIText(Text gt, Vector2 vec)
    {
        if(gt!=null)
        {
            Vector2 v = gt.pixelOffset;
            v.x *= vec.x;
            v.y *= vec.y;       
            gt.pixelOffset = v;
        }
    }

Just looked into this more… GUIText and GUITexture are gone now. You would need to convert to using the UnityEngine.UI namespace, which also now comes in a package.

If you have like 5 of these things, just remake the UI. There’s tons of tutorials on the “new” UI, which is actually new in 2014, so it’s already 7 years old.

If you have like 500 of these things, it might be worth trying to write some kind of automation to trans-map them into some kind of emulated GUI layer, but it would be some work.

thanks for the info. that all seems logical. So how does one actually automate this with some kind of GUI layer? and where are these tutorials? I have looked and found the guitext conversion but not much with guitexture.

Google UnityEditor tutorials.

I imagine you’d make this into a UI.Image object.

The GUIText would probably become a UI.Text or a TextMeshPRO thing