GUItexture not accepting mouse clicks

I applied a script to my guiTexture and it stopped accepting mouse clicks…anytime i disable the script the texture accepts mouse clicks.The script is below.

var x,y,a,b:float = 0.5;

    function Update() {
        var myTexture:GUITexture = GetComponent(GUITexture);
        myTexture.pixelInset = Rect (x*Screen.width, y*Screen.height, a*Screen.width, b*Screen.height);
    }

How do you get the mouse click? GUITexture has no collider so you need to convert the mouse position to screen and then check for Rect intersection.

–

Please explain more don't really understand

–

Usually you have to assign a Collider component to the Object to get the Object responding the Click Event. Unfortunately, GUITexture objects can't have a Collider component. What fafase was trying to say is that you should check the position of the cursor when clicking, and if it is inside the rectangle where your GUITexture is, call the event.

–

yeah thanks.....figured a way round this challenge

–

1 Answer

1

I don’t personally know myself. But, I found this video and it helped me make mine.

Keep in mind this is a 2 part video.