- Home /
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.
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.
Answer by sparky14 · Nov 27, 2013 at 10:48 AM
I don't personally know myself. But, I found this video and it helped me make mine.
https://www.youtube.com/watch?v=yjCEGIVj84Q
Keep in mind this is a 2 part video.