GUITexture: Disabling Touch position?

Hi

The situation I have, is that my App is made up of all GUITextures, that are layered on the z position.

Some of these GUITextures link to other game elements and react on touch events.

My question is, where do I start (search?) in order to find out how to tell the touch event that it will only activate when its assigned GUITexture is in a certain area (say middle) of the screen?

What I’m trying to do is avoid is where I will have two textures, each with its own unique event when touched. But if they are on top of each other, the incorrect event (eg the texture on the bottom) gets called on touch, rather than the top texture to which I’d want to assign a priority?

God I hope this all makes sense to someone :stuck_out_tongue:

Thanks for any guidance. Please ask if you need further interpretation of the above. Its 1am and I’m not exactly thinking straight :stuck_out_tongue: :stuck_out_tongue:

You probably wouldn’t tell the touch event not to activate, but probably only have the GUIElement respond if it is at a certain layer and position.

So in the GUI script you would check did the user tap any where, yes, then you check if the this object is at a certain depth. If it is then check the position of the mouse and see it they overlap.

Or, you could just disable the scripts on your GUI when they are not visible. Then you don’t have to worry about the layer, and turn them back on when they become visible again.

Yeah, I’ll give that depth thing a go - that’s a good idea…

I’ll post back my findings :stuck_out_tongue:

Cheers

Gave it a shot. I’m using:

if(iPhoneInput.touchCount > 0)
			{
				var touch: iPhoneTouch = iPhoneInput.touches[0]; 
 				
 				if(touch.phase == iPhoneTouchPhase.Stationary  HitTest(touch.position.Vector3(0,0,10)))
 				{
 					
									
					   			  		
   					iTween.moveToUpdate(cam,{"x" : 10, "time": 1});
   					   					
 				}
       }
}

This does nothing to resolve it.

Should I be using Vector2 or Vector3??

The way the GUITextures are set up are:
Transforms 0,0,10 (depth)

Pixel inset used to position them on screen.

Am I going about this all wrong perhaps with positioning?

HitTest is an instance method of GUITexture, so you have to use guiTexture.HitTest().

I would make a temporary sturct (no memory issues) to work with your touch position because it doesn’t look right to me. at the moment.

var touchPos : Vector3 = touch.position;
touchPos.z = 10;

if(touch.phase == iPhoneTouchPhase.Stationary  guiTexture.HitTest(touchPos)) 
{                           
                                    
        iTween.moveToUpdate(cam,{"x" : 10, "time": 1}); 
                                     
}

PS. I haven’t tested this yet, so cross your fingers for typos.

Don’t forget, iTwee.moveToUpdate() is meant for moving/changing positions :wink:

Thanks for this. I normally do have guiTexture for HitTest - not sure why it wasn’t in my script >< Ech.

I’ll give this a shot and see what happens :slight_smile: Cheers.

Yes :slight_smile: It’s exactly what I need.