Distinguish buttons

Hi Guys,

I’m very confused, to place the style for each button i cant distinguish the button by tool tip, what can i do to get one function on mouse over and other on mouse down.

http://testeunity.mariojmcarvalho.com/

First i place one GUItexture in game objects, to do the guy of the left. Because i couldn’t positioned well, i start from the scrath this one, in the middle, but now i can’t do mouse over and mouse down in the same button.

Other thing, because i have button with different images, i need a GUIStyle for each?

I can distinguish the buttons by the normal or hover state image that they have?

public class GUI_360_Rot : MonoBehaviour {;

	public Texture2D img_Bt_Arrow_Up = null;
	public Texture2D img_Bt_Arrow_Down = null;
	public Texture2D img_Bt_Arrow_Left = null;
	public Texture2D img_Bt_Arrow_Right = null;
	
	public GUIStyle style_Bt_Arrow_Up;
	public GUIStyle style_Bt_Arrow_Down;
	public GUIStyle style_Bt_Arrow_Left;
	public GUIStyle style_Bt_Arrow_Right;
	
	public string tooltip = null;
	
	void OnGUI(){

		
		GUI.BeginGroup(new Rect(Screen.width / 2 - 75 , Screen.height - 170, 150, 150));
		
		//////////////////
		
		GUI.Button(new Rect (50,0,50,50),img_Bt_Arrow_Up, style_Bt_Arrow_Up);
		
		GUI.Button(new Rect (50,100,50,50),img_Bt_Arrow_Down, style_Bt_Arrow_Down);
		
		GUI.Button(new Rect (0,50,50,50),img_Bt_Arrow_Left, style_Bt_Arrow_Left);
		
		GUI.Button(new Rect (100,50,50,50),img_Bt_Arrow_Right, style_Bt_Arrow_Right);

		
			}
	
        GUI.EndGroup();
				
	}
}

Thanks :slight_smile:

  1. You don’t need a separate GUIStyle for each button. Check out the GUIContent parameter of the GUI.Button method.

  2. You can distinguish the buttons by examining the returned (boolean) value:

var upButtonClicked = GUI.Button(new Rect (50,0,50,50),img_Bt_Arrow_Up, style_Bt_Arrow_Up);