Like said above just use the OnClick event in the inspector. Here’s what I do for UI.
Make a new script for managing button clicks.
Attach this script to some Gameobject in your scene.
In the script, make a new public function for what you want your button to do…for example
public void playButton() { Application.LoadLevel("Krolsch"); }.
Now click on your button in the hierarchy and find the little area in the inspector that says "On Click () "
Click the little plus symbol
This will add somthing with 2 drop down menus and an input thing that says “None (Object)”. Drag the game object that has your button script on it into that field that says “None (Object)”.
This will let you reference this object. Click on the drop-down menu that says “No Function” and it will show some options. Click on the one that is the same name as the script you made earlier and then click on the function name. This will make the button run this function.
For example, my script is called ButtonManager and my function was called playButton