OverviewButton is a simple component designed to receive hover, pressed and click events, and change the color of a remote sprite. You can also optionally attach an Image Button component to the same game object to get sprite swapping functionality as well.
A button can be anything. It doesn't have to be a widget. You can put a Button component on anything that has a collider. Regardless, you will most commonly be using the Button component in your UI hierarchy -- generally alongside a UI Sprite or on the game object directly above it.
In order for the button to work, the camera that's drawing the object where you place the Button component must have a
UICamera script attached, as that's what sends out events. You must also have "Raycast Hit Triggers" turned on in the Physics Settings in your project.
Button works by receiving mouse over, press and click events, and translates them into appropriate color-changing actions on your the object specified in your
Target field. This will most commonly be a widget (sprite, label, or texture), but can also be an object with a Light, or even a Renderer.
If you want to trigger a remote function when you click on the button, drag & drop the target game object into the "Notify" field, then choose the function from the drop-down list. Note that in order for the function to show up, it must be of "public void FuncName (void)" type. For example:
public void MyClickFunction()
{
Debug.Log("I was clicked!");
}
Built-in components, such as tweens, have an assortment of pre-made functions for you to choose from (for example: PlayForward).
Pro-Tip #1It's generally a good idea to put the Button component on the same game object as the button's background sprite. Hit ALT+SHIFT+C to quickly create a collider, and check the "Box Collider" option on the sprite so that the box collider auto-updates as you resize the sprite.
Pro-Tip #2UIButton comes with only an
OnClick notification. If you want
OnPress, OnHover, OnSelect, OnDoubleClick, and/or others -- attach
UIEventTrigger script to your button (or any other object for that matter).
Class Documentationhttp://tasharen.com/ngui/docs/class_u_i_button.htmlIf you have a question regarding this component or would like me to clarify something, just post a reply here.