Skip to main content

InputFieldPlaceholderRemover

Important Attention Reminder

Coding Style wiki


InputFieldPlaceholderRemover is the input field helper shipped with ButtonSystem (a MonoBehaviour component, see Module Intro); attach it onto the same GameObject as an InputField (Legacy) or TMP_InputField and the Placeholder is hidden automatically while the input field is focused (editing) and restored after it loses focus — pure component behavior, effective as soon as it is attached, no API calls needed.

NamespaceOxGKit.ButtonSystem
Typepublic class InputFieldPlaceholderRemover : MonoBehaviour
SourceInputFieldPlaceholderRemover.cs
using OxGKit.ButtonSystem;

Quick Start

  1. On the object holding the InputField (Legacy) or TMP_InputField, use Add Component -> InputFieldPlaceholderRemover.
  2. Done — enter Play Mode and click the input field: the Placeholder hides automatically on focus and reappears on defocus.

It can also be attached at runtime:

using OxGKit.ButtonSystem;
using TMPro;
using UnityEngine;

public class SetupInputField : MonoBehaviour
{
public TMP_InputField inputField;

private void Awake()
{
// Attaching onto the same object as the input field is all it takes
this.inputField.gameObject.AddComponent<InputFieldPlaceholderRemover>();
}
}

General Rules

Supported Input Field Types

Input FieldImplementation
TMP_InputFieldEvent driven via onSelect / onDeselect: hides the Placeholder on select, restores it on deselect.
InputField (Legacy)Polled per frame in Update via isFocused: hides the Placeholder while focused, restores it when focus is lost.

Attachment Rules

  • The component grabs the InputField and TMP_InputField references on the same GameObject in Awake, so it must live on the same object as the input field (attaching it to a parent or child object has no effect).
  • The component exposes no public API members — its behavior is fully automatic, with no configuration needed (or possible).

Attention The input field must have its Placeholder assigned (the default UGUI structure already has one); the component toggles it via placeholder.gameObject.SetActive.

Reminder When attaching at runtime, make sure the input field component already exists on the object before calling AddComponent, so Awake can grab the input field reference.