Back to API Reference
Class

InputCaretRenderer

Lightweight UI graphic that renders the text input caret as a filled rectangle. This is the caret extension point: subclass and override OnPopulateMesh (reading CaretRect / BlinkVisible) for custom shapes — block cursor, underline, gradient — then assign via CaretRenderer.

Remarks

Inherits MaskableGraphic so the caret participates in RectMask2D clipping within the input field viewport. Blink behavior: the caret toggles visibility every CaretBlinkInterval seconds. After CaretBlinkTimeout seconds of inactivity the caret stops blinking and remains visible. Any user interaction (typing, cursor movement, selection change, focus) should call ResetBlink to restart the cycle.
public static bool PrefersNonBlinkingCaret{ get; set }

Application-wide accessibility flag: when, caret renderers suppress the blink animation and keep the caret continuously visible. Mirrors iOS 17+ "Prefer Non-Blinking Cursor" and the macOS Reduce Motion cursor sub-setting — surface the platform pref here from your integration layer, alongside PrefersReducedMotion.

public float CaretWidthRatio{ get; set }

Caret width as a fraction of the caret's height (which tracks the component's font size), so the caret keeps the same proportion to the text at any canvas scale or resolution. The default renderer draws the rectangle this wide; custom shapes may ignore or reinterpret it.

protected Rect CaretRect{ get }

Latest caret rectangle in local coordinates, for subclass mesh builders.

protected bool BlinkVisible{ get }

Current blink phase, for subclass mesh builders: false = the caret is in its invisible half-cycle.

protected override void Awake()
public virtual void SetCaretPosition()

Updates the caret rectangle in local coordinates and repaints.

protected override void OnPopulateMesh()
protected override void OnEnable()
protected override void OnDisable()
public static Action PrefersNonBlinkingCaretChanged

Occurs when PrefersNonBlinkingCaret has changed so observers can re-arm visuals. InputCaretRenderer subscribes automatically.