tk2dUIItem Class Reference

UI primary class. All colliders that need to response to touch/mouse events need to have this attached. This will then handle and dispatch events. More...

List of all members.

Public Member Functions

void UpdateParent ()
 If you change the parent (in hierarchy) call this. If isChildOfAnotherUIItem is false, will act as if it is true.
void ManuallySetParent (tk2dUIItem newParentUIItem)
 Manually setting specific UIItem parent.
void RemoveParent ()
 Will remove parent and act as if isChildOfAnotherUIItem is false.
bool Press (tk2dUITouch touch)
 Touch press down (only call manually, if you need to simulate a touch)
bool Press (tk2dUITouch touch, tk2dUIItem sentFromChild)
 Touch press down (only call manually, if you need to simulate a touch). SentFromChild is the UIItem child it was sent from. If sentFromChild is null that means it wasn't sent from a child.
void UpdateTouch (tk2dUITouch touch)
 Fired every frame this touch is still down, regardless if button is down. Only call manually if you need to simulate a touch.
void Release ()
 Touch is released, if called without Exit being called means that it was released on top of button without leaving it. Only call manually if you need to simulate a touch.
void CurrentOverUIItem (tk2dUIItem overUIItem)
 Touch/mouse currently over UIItem. If exitting this button, but still overtop of another Button, this might be a parent. Checks if parent and does not exit. Only call manually if you need to simulate touch.
bool CheckIsUIItemChildOfMe (tk2dUIItem uiItem)
 Is uiItem a child of this current tk2dUIItem Only call manually if you need to simulate touch.
void Exit ()
 Exit uiItem. Does not cascade (need to manually call on all children if needed) Only call manually if you need to simulate touch.
bool HoverOver (tk2dUIItem prevHover)
 Hover over item. Return true if this was prevHover. Only call manually if you need to simulate touch.
void HoverOut (tk2dUIItem currHoverButton)
 Hover out item. Only call manually if you need to simulate touch.
void SimulateClick ()
 Simluates a click event Only call manually if you need to simulate touch.
void InternalSetIsChildOfAnotherUIItem (bool state)
 Internal do not call.

Public Attributes

GameObject sendMessageTarget = null
 Target GameObject to SendMessage to. Use only if you want to use SendMessage, recommend using events instead if possble.
string SendMessageOnDownMethodName = ""
 Function name to SendMessage OnDown.
string SendMessageOnUpMethodName = ""
 Function name to SendMessage OnUp.
string SendMessageOnClickMethodName = ""
 Function name to SendMessage OnClick.
string SendMessageOnReleaseMethodName = ""
 Function name to SendMessage OnRelease.
bool registerPressFromChildren = false
 If this UIItem is a hierarchy parent of another UIItem that is marked as isChildOfAnotherUIItem, and you wish to receive touch/click/hover events from child.
bool isHoverEnabled = false
 If this UIItem should receive hover events (if hover enabled(tk2dUIManager.areHoverEventsTracked), mouse is being used and multi-touch is diabled(tk2dUIManager.useMultiTouch))

Properties

bool IsPressed [get]
 If currently pressed (down)
tk2dUITouch Touch [get]
 If pressed active touch event.
tk2dUIItem ParentUIItem [get]
 If set as child of another UIItem, this is that parentUIItem.

Events

System.Action OnDown
 Pressed.
System.Action OnUp
 Unpressed, possibly on exit of collider area without releasing.
System.Action OnClick
 Click - down and up while not leaving collider area.
System.Action OnRelease
 After on down, when touch/click is released (this could be anywhere)
System.Action OnHoverOver
 On mouse hover over (only if using mouse, hover is enabled(tk2dUIManager.areHoverEventsTracked) and if multi-touch is disabled(tk2dUIManager.useMultiTouch))
System.Action OnHoverOut
 On mouse hover leaving collider (only if using mouse, hover is enabled(tk2dUIManager.areHoverEventsTracked) and if multi-touch is disabled(tk2dUIManager.useMultiTouch))
System.Action< tk2dUIItemOnDownUIItem
 Same as OnDown above, except returns this tk2dUIItem.
System.Action< tk2dUIItemOnUpUIItem
 Same as OnUp above, except returns this tk2dUIItem.
System.Action< tk2dUIItemOnClickUIItem
 Same as OnClick above, except returns this tk2dUIItem.
System.Action< tk2dUIItemOnReleaseUIItem
 Same as OnRelease above, except returns this tk2dUIItem.
System.Action< tk2dUIItemOnHoverOverUIItem
 Same as OnHoverOver above, except returns this tk2dUIItem.
System.Action< tk2dUIItemOnHoverOutUIItem
 Same as OnHoverOut above, except returns this tk2dUIItem.

Detailed Description

UI primary class. All colliders that need to response to touch/mouse events need to have this attached. This will then handle and dispatch events.


Member Function Documentation

Is uiItem a child of this current tk2dUIItem Only call manually if you need to simulate touch.

Touch/mouse currently over UIItem. If exitting this button, but still overtop of another Button, this might be a parent. Checks if parent and does not exit. Only call manually if you need to simulate touch.

void tk2dUIItem.Exit ( )

Exit uiItem. Does not cascade (need to manually call on all children if needed) Only call manually if you need to simulate touch.

void tk2dUIItem.HoverOut ( tk2dUIItem  currHoverButton)

Hover out item. Only call manually if you need to simulate touch.

bool tk2dUIItem.HoverOver ( tk2dUIItem  prevHover)

Hover over item. Return true if this was prevHover. Only call manually if you need to simulate touch.

Internal do not call.

void tk2dUIItem.ManuallySetParent ( tk2dUIItem  newParentUIItem)

Manually setting specific UIItem parent.

bool tk2dUIItem.Press ( tk2dUITouch  touch)

Touch press down (only call manually, if you need to simulate a touch)

bool tk2dUIItem.Press ( tk2dUITouch  touch,
tk2dUIItem  sentFromChild 
)

Touch press down (only call manually, if you need to simulate a touch). SentFromChild is the UIItem child it was sent from. If sentFromChild is null that means it wasn't sent from a child.

///

return true if newly pressed

Touch is released, if called without Exit being called means that it was released on top of button without leaving it. Only call manually if you need to simulate a touch.

Will remove parent and act as if isChildOfAnotherUIItem is false.

Simluates a click event Only call manually if you need to simulate touch.

If you change the parent (in hierarchy) call this. If isChildOfAnotherUIItem is false, will act as if it is true.

Fired every frame this touch is still down, regardless if button is down. Only call manually if you need to simulate a touch.


Member Data Documentation

If this UIItem should receive hover events (if hover enabled(tk2dUIManager.areHoverEventsTracked), mouse is being used and multi-touch is diabled(tk2dUIManager.useMultiTouch))

If this UIItem is a hierarchy parent of another UIItem that is marked as isChildOfAnotherUIItem, and you wish to receive touch/click/hover events from child.

Function name to SendMessage OnClick.

Function name to SendMessage OnDown.

Function name to SendMessage OnRelease.

Function name to SendMessage OnUp.

GameObject tk2dUIItem.sendMessageTarget = null

Target GameObject to SendMessage to. Use only if you want to use SendMessage, recommend using events instead if possble.


Property Documentation

If currently pressed (down)

If set as child of another UIItem, this is that parentUIItem.

If pressed active touch event.


Event Documentation

System.Action tk2dUIItem.OnClick

Click - down and up while not leaving collider area.

Same as OnClick above, except returns this tk2dUIItem.

System.Action tk2dUIItem.OnDown

Pressed.

Same as OnDown above, except returns this tk2dUIItem.

System.Action tk2dUIItem.OnHoverOut

On mouse hover leaving collider (only if using mouse, hover is enabled(tk2dUIManager.areHoverEventsTracked) and if multi-touch is disabled(tk2dUIManager.useMultiTouch))

Same as OnHoverOut above, except returns this tk2dUIItem.

System.Action tk2dUIItem.OnHoverOver

On mouse hover over (only if using mouse, hover is enabled(tk2dUIManager.areHoverEventsTracked) and if multi-touch is disabled(tk2dUIManager.useMultiTouch))

Same as OnHoverOver above, except returns this tk2dUIItem.

System.Action tk2dUIItem.OnRelease

After on down, when touch/click is released (this could be anywhere)

Same as OnRelease above, except returns this tk2dUIItem.

System.Action tk2dUIItem.OnUp

Unpressed, possibly on exit of collider area without releasing.

Same as OnUp above, except returns this tk2dUIItem.