Skip to main content

Class InputPromptView

Represents a single UI prompt for one interaction option on an interactable object. Displays the corresponding input (e.g., button or key), visualizes interaction progress with a fill bar, and updates its state based on player input and interaction status.

Works in coordination with InteractionView to ensure only the selected prompt remains active, while other InputPromptView instances are visually and functionally locked.

[RequireComponent(typeof(CanvasGroup))]
public class InputPromptView : MonoBehaviour

Inheritance​

Methods​

ActivateInputPromptTypeWriter()​

Triggers a typewriter animation effect for the prompt text.

public void ActivateInputPromptTypeWriter()

Lock()​

Set the prompt UI to lock state and update the visual to reflect that.

public void Lock()

PressDown()​

Starts holding this prompt's button, as a key down or a hand touching the prompt does.

public void PressDown()

PressUp()​

Stops holding this prompt's button, as a key up or a hand leaving the prompt does.

public void PressUp()

ReleaseLock()​

Unlocks the prompt and update the visual to reflect that.

public void ReleaseLock()

SetFillTarget(float)​

Sets the target value for the fill bar.

public void SetFillTarget(float fillTarget)

Parameters​

NameTypeDescription
fillTargetfloatTarget fill value.

SetInputPrompt(string, float)​

Updates the interaction prompt text, optionally appending duration.

public void SetInputPrompt(string newText, float duration = 0)

Parameters​

NameTypeDescription
newTextstringPrompt message.
durationfloatOptional duration to show beside text.

TweenFillBarToTargetValue(float, float)​

Smoothly animates the fill bar to a target value.

public void TweenFillBarToTargetValue(float targetFill, float duration = 0)

Parameters​

NameTypeDescription
targetFillfloatTarget fill value.
durationfloatTween duration.

Held​

Raised every frame while the action is held.

public event Action Held

Event Type​

Action

Pressed​

Raised when this prompt's action is first pressed. Argument is the option index.

public event Action Pressed

Event Type​

Action

Released​

Raised when the action is released.

public event Action Released

Event Type​

Action

  • Methods
    • ActivateInputPromptTypeWriter()
    • Lock()
    • PressDown()
    • PressUp()
    • ReleaseLock()
    • SetFillTarget(float)
    • SetInputPrompt(string, float)
    • TweenFillBarToTargetValue(float, float)
    • Held
    • Pressed
    • Released