Skip to main content

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.

Constructors​

MemberWhat it is
TouchScreenButtonVisual()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

MemberWhat it is
protected static readonly int _AlphaShader property ID for _Alpha.
8 private and internal fields
MemberWhat it is
private Renderer[] allRenderersAll renderers that get the button material.
private Button buttonThe button this visual follows.
private AltaCoroutine growRoutineThe running grow coroutine, if any.
private TextRenderer labelRendererOptional text renderer that shows the button's label.
private Renderer mainRendererThe main renderer whose material alpha changes.
private Material materialThis button's own copy of the settings material.
private TouchScreenButtonVisualSettings settingsThe button's current visual settings.
private Vector3 startingScaleThe button's local scale at Awake, restored after the grow animation.

Methods​

MemberWhat 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
MemberWhat 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.