- Home /
 
               Question by 
               Ilkzz · Feb 10, 2014 at 01:42 PM · 
                guitouchguitexture  
              
 
              Touch point not detected correctly on GUI Texture
My buttons are working correctly. The texture swaps when i touch the texture and when I let go. However, the problem is it doesn't detect the accurately.
When I touch a little below the button, it still works when I don't want it to.
My code is below. I do think I'm on the right tracks.
 var targetGui : GUITexture;
 var hoverTex : Texture2D;
 var normalTex : Texture2D;
 
 function Start () {
 
 }
 
 function Update(){
     if (Input.touchCount == 1)
     {
         var touch: Touch = Input.touches[0]; 
  
         if(touch.phase == TouchPhase.Began && guiTexture.HitTest(touch.position))
                {
                targetGui.texture = hoverTex;
             //Application.LoadLevel("Level 1");
                } 
         if(touch.phase == TouchPhase.Ended && guiTexture.HitTest(touch.position))
                {    
             targetGui.texture = normalTex;
             }
     }
 }
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Xitech_ · Feb 10, 2014 at 02:45 PM
It could be that the texture is wrong(the texture image). Try making a complete black image and use that as button
Answer by Shahroz Ahmed Harral · May 28, 2014 at 09:33 AM
replace if(touch.phase == TouchPhase.Began && guiTexture.HitTest(touch.position))
with
if(touch.phase == TouchPhase.Began && targetGui.HitTest(touch.position))
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                