you can useOnGUI for button and to disappear the rectangle you have to make a new GUIStyle
private GUIStyle testStyle = new GUIStyle();
public Texture2D Texture1;
void OnGUI(){
if( GUI.Button( new Rect (0, 0, 100, 100) , texture1 ,testStyle) )
{
//doSomething if clicked on
}
}
if you dont want that you can do a raycasting your selfand give your buttons tags like below
void Update () {
if (Input.GetMouseButtonDown (0)) {
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit)) {
if(hit.collider.tag=="play")
//DoSomething
}
}
}
in unity 4.6 UI you can add listeners to buttons in script like below
private Button MyButton = null; // assign in the editor
void Start()
{
MyButton.onClick.AddListener(() => { somefunction(); });
}