Why is only my last for-loop-button triggering?


I have this drop-down menu in my game which uses a for-loop to display a button for every instance in a list:

		if( selectedItem != emptyItem){
		var rightClickRect : Rect = Rect( selectedItemLoc.x, selectedItemLoc.y, widthSlot * 3, selectedItem.usages.Count * widthSlot + widthSlot  * 2 );
		GUI.Box( rightClickRect, "Choose an option: ");
			for( var u : int = 0; u < selectedItem.usages.Count; u++){
				if( GUI.Button( Rect( rightClickRect.x + widthSlot * 0.2, rightClickRect.y  + ( breedteSlot * u ) + widthSlot * 0.5, widthSlot * 2.6 , widthSlot ), selectedItem.usages.name)){
			Debug.Log( "Called UseItem");

I’m sorry that the button/box location maths are so messy.
Anyway whenever the ‘selectedItem’ only has one instance in its ‘usages’ the button which the for-loop generates simply won’t trigger, the Debug.Log won’t show up.
if it has 2 or more instances only the last button will trigger.
Any ideas why this is?


It turned out that using the ‘if( Rect.Contains)’ method does work, I still don’t know why this won’t work though. :confused:

anyway this works so yeah…