Skip to content

Add Clear and ClearAll methods to WebGLInput#184

Open
dannykoh wants to merge 1 commit into
kou-yeung:masterfrom
dannykoh:master
Open

Add Clear and ClearAll methods to WebGLInput#184
dannykoh wants to merge 1 commit into
kou-yeung:masterfrom
dannykoh:master

Conversation

@dannykoh

Copy link
Copy Markdown

Summary
Implemented two new methods for input field management.

  • Clear() — Resets the text content of a single input field on both Unity and HTML sides.
  • ClearAll() — Clears all input fields simultaneously.

Details
These methods provide a programmatic way to reset input fields, ensuring that users start with a clean state when entering new data. Without invoking these methods, previously entered text values may persist across sessions and unintentionally override new inputs.

Introduced Clear() to reset the text of a single input field on both Unity and HTML sides, and ClearAll() to clear all input fields. These methods help ensure input fields can be programmatically reset as needed.
@kou-yeung

Copy link
Copy Markdown
Owner

Thanks for the PR! 🙏

WebGLInput is designed so that just attaching the component should handle syncing automatically —
usually setting InputField.text = "" or TMP_InputField.text = "" clears the HTML side when the user starts typing again.

Could you clarify why adding Clear() / ClearAll() was needed?

  • Does .text = "" fail to sync in some cases?
  • If so, could you share the conditions or steps to reproduce it (e.g. focus lost, UI re-open, DOM not yet created)?
  • Any specific Unity or browser environment involved?

Understanding that would help decide whether we need a new API or just improve the existing sync behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants