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
}
///////////////////////////////////