UI System?
No, it's not a replacement for Unity's native UI systems. There are enough of those already!
It's a way to have click/touch and hover type interactions with on-screen TPT tiles and can be used to add interactivity to tiles. But there's no UI builder - you have to lay out and configure everything manually.
Generally, you create a UI-Capable tile by implementing the ITpUiControl interface. However, it's recommended that you try to use the suppled UI tile varieties if possible or use those as base classes.
The tiles are controlled by messages: the easiest way to use this is to use the TpInputActionToTile component.
ItpUiControl has two main functions:
- Get information about supported effects and start an effect.
- Set values and get values in various formats.
Setting values is done with one method implementation: SetValue(object value, bool withNotify = true)
You convert the object into whatever your tile requires.
Getting values is done with several implementations for various formats: int, bool, object, string, or Char.
A control can use the AcceptsClicks
and AcceptsHover
to control what sort of messages it gets.
For example, a control that normally accepts clicks can temporarily return false from the AcceptsClicks
property if it is still executing an effect such as a tween which hasn't completed yet. A second click can be inhibited until the effect is complete.
AcceptsHover
should only be true if you want to get Hover messages: these are very frequent since they're continually sent while the mouse or other pointer is moving.
SupportedEffects
returns a flags enum that specifies various types of effects such as BumpSize, BumpColor, etc. Return a value which describes which effects your tile actually implements.
RunEffect
is used to execute an effect. You can add duration, Vector3, and/or Color endpoint values to use for tweening or color changes.