> ## Documentation Index
> Fetch the complete documentation index at: https://docs-unity.molca.id/llms.txt
> Use this file to discover all available pages before exploring further.

# CodeInputStep

> Numeric or code entry step completion.

**File:** `Assets/_MolcaSDK/_VR/Scripts/Scenario/Steps/CodeInputStep.cs`\
**Base:** [Step](/core/step)

## When to use

Use `Code Input Step` when a VR training scenario needs this specific interaction as a step in a sequence. Configure entirely in the Inspector — no code required.

## Role

Completes when the trainee enters the expected code sequence (see Inspector for length, validation, and UI hooks). Often pairs with shared [Modals](/shared/modals) / keyboard widgets.

## Code

**`CodeInputPanel.onCodeValidated`** → **`OnCodeValidated`** → **`ValidateCode`**; if valid, **`Complete()`**. Validation uses **`expectedCode`** only when **`useStepExpectedCode`** (panel-driven otherwise; **`onCodeValidated`** implies panel accepted input). **`autoShowPanel`**, **`showInVR`** + offset, **`hideOnComplete`**, **`resetOnActivate`** control UI.

```csharp theme={null}
using MolcaSDK.VR.Scenario;

public class PinLesson : UnityEngine.MonoBehaviour
{
    public CodeInputStep step;

    private void OnEnable()
    {
        step.SetExpectedCode("1234");
        // step.ForceComplete(); // escape hatch
    }
}
```

## Troubleshooting

* **No CodeInputPanel** — Assign or place **`CodeInputPanel`** on/under the same GameObject; auto-find runs in **`Initialize`**.
* **Always invalid** — If relying on step code, enable **`useStepExpectedCode`** and set **`expectedCode`** (or **`SetExpectedCode`**). Otherwise configure the panel’s own expected code so **`onCodeValidated`** only fires when correct.
* **Panel not visible in HMD** — Enable **`showInVR`**, adjust **`vrPositionOffset`**, ensure **`Camera.main`** exists for placement.

## Related

* [Step (base class)](/core/step)
* Shared UI — search **`CodeInputPanel`** under **`_MolcaSDK/Code/`**

## Unity Editor

<Frame hint="CodeInputStep + in-scene code panel." caption="CodeInputStep Inspector">
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/ptmolcateknologinusantara/images/features/vr/steps/code-input-step-inspector.png" alt="CodeInputStep in Unity Inspector" />
</Frame>
