TouchScreenButtonVisual
A class in Root.Township, Alta.Meta.UI.
Visual feedback for a touch screen button: sets its material and label from the button's TouchScreenButtonVisualSettings, changes alpha when pressed and plays a grow animation. Client UI.
- Listed in Menus, UI and platforms
- Inherits or implements
MonoBehaviour
Constructors
| Member | What it is |
|---|---|
TouchScreenButtonVisual() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
protected static readonly int _Alpha | Shader property ID for _Alpha. |
8 private and internal fields
| Member | What it is |
|---|---|
private Renderer[] allRenderers | All renderers that get the button material. |
private Button button | The button this visual follows. |
private AltaCoroutine growRoutine | The running grow coroutine, if any. |
private TextRenderer labelRenderer | Optional text renderer that shows the button's label. |
private Renderer mainRenderer | The main renderer whose material alpha changes. |
private Material material | This button's own copy of the settings material. |
private TouchScreenButtonVisualSettings settings | The button's current visual settings. |
private Vector3 startingScale | The button's local scale at Awake, restored after the grow animation. |
Methods
| Member | What it is |
|---|---|
protected void SetAlpha(bool isPressed) | Sets the material's _Alpha to the pressed or idle value from the settings. |
11 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Makes a per-button material copy from the settings, applies it to all renderers, sets the label and subscribes to the button's events. |
private IEnumerator GrowButton() (iterator) | Coroutine that scales the button over GrowDuration using the settings' GrowCurve. |
private void LabelChanged(Button button) | Copies the button's new label to the label renderer. |
private void OnDestroy() | Cleans up the material copy. |
private void OnDisable() | Resets the scale and sets the alpha back to idle. |
private void OnValidate() | Editor: fills renderers from a BasicTouchScreenButton if missing and applies the settings' colour material. |
private void Pressed(Button button) | On press, sets pressed alpha and starts the grow animation. |
private void Released(Button button) | On release, sets idle alpha and resets the scale. |
private void ResetScale() | Stops the grow animation and restores the starting scale. |
private void SettingsChanged(Button button) | Rebuilds the material from the new settings and keeps the current alpha position between idle and pressed. |
private void StartGrow() | Restarts the grow coroutine if the component is active. |