Default rect is unknown identifier?

Here is my code:

@script RequireComponent( GUITexture )
private var gui : GUITexture;


function Start()
{
    gui = GetComponent( GUITexture );
    defaultRect= gui.pixelInset;
    
    }
    function Update()
    {
    var count = Input.touchCount;
    for(var i : int = 0;i< count; i++)
    {
    var touch : Touch = Input.GetTouch(i);
    
    if (gui.HitTest( touch.position ))
    
    {
    
    gui.pixelInset.x = touch.position.x;
    gui.pixelInset.y = touch.position.y;
    
    }
    }
    }

And here are the errors I get

Unknown identifier: default rect.

Any ideas?

Hi

You don’t declare your defaultRect variable

replace

defaultRect= gui.pixelInset;

with

var defaultRect= gui.pixelInset;

NOTE: (!)
I can’t see any code using this variable so you could probably just delete it.

If you need defaultRect in other methods (functions) you need to declare it where you declared the private gui variable:

private var gui : GUITexture;  // You already have this line
private var defaultRect; 

PS - make sure to tick and vote the answers that helped you in unity answers :slight_smile: