ZenCoder Component
The ZenCoder Component is the heart of the ZenCoder system. It’s a lightweight, self-contained runtime scripting unit that lives inside your GameObject and provides live, context-aware code execution directly within the Unity Inspector.
How to Add It?
You can add the component in two ways:
-
From the Hierarchy
Right-click on any GameObject in the Hierarchy > Attach ZenCoder`. -
From the Inspector
Select your GameObject > clickAdd Component
> search for ZenCoder.
How It Works?
ZenCoder adds a fully integrated code editor inside the Unity Inspector.
You can write C# directly with full IntelliSense, syntax highlighting, and contextual reflection.
ZenCoder supports a wide range of Unity lifecycle methods, including initialization, update loops, physics, rendering, gizmos, input, and more — all working as they would in a standard MonoBehaviour
.
Example:
public class ZenCoder
{
public void Start()
{
// Initialization logic
Debug.Log("ZenCoder started");
}
public void Update(float deltaTime)
{
// Per-frame logic
Debug.Log($"Frame updated: {deltaTime}");
}
public void OnDrawGizmos()
{
// Visual debugging or custom scene visuals
Gizmos.color = Color.cyan;
Gizmos.DrawSphere(transform.position, 0.5f);
}
}
ZenCoder supports both editor-safe and runtime lifecycle events — from
Awake()
andOnValidate()
toOnDrawGizmos()
, physics events, and more.
Writing Code
You can write two main kinds of logic:
-
Instant logic — one-time actions such as initialization, value assignment, or logging.
-
Continuous logic — frame-based behavior such as movement, animation, timers, or dynamic effects.
Example:
public class ZenCode
{
private float timer;
public void Start()
{
Debug.Log("Zen initialized");
}
public void Update(float deltaTime)
{
timer += deltaTime;
if (timer >= 1f)
{
Debug.Log("One second has passed.");
timer = 0f;
}
}
}
ZenCoder runs live. You can modify and re-execute methods instantly without stopping Play Mode or recompiling scripts.
Context-Aware Suggestions
ZenCoder introduces a contextual keyword: target
.
This represents the selected component from the ZenCoder toolbar, giving you full access to its fields, properties, and methods with intelligent auto-completion.
How it works:
-
Typing
target.
inside the editor triggers a reflection-based suggestion list. -
You’ll see all available members, grouped by type (fields, properties, methods).
-
Deep reflection is supported — nested members can be explored progressively as you type.
Example:
Reflection updates automatically when you switch the selected component — no setup or caching required.
Suggestions remain lightweight, responsive, and fully aware of your current context.
Error Handling
ZenCoder provides a streamlined, non-intrusive error reporting system designed for fast feedback and focused debugging — all within the Inspector.
When code contains errors:
-
Line Highlights
Any line that fails compilation will be highlighted with a generic error marker to indicate there's an issue. -
Status Bar Navigation
The ZenCoder status bar displays the full error message for the currently selected error.
Use the built-in navigation arrows (<
/>
) to move between errors. As you navigate, the corresponding line in the code editor is highlighted. -
Optional Unity Console Logging
If Preferences > Log Compilation Errors is enabled, ZenCoder will also mirror error messages to the Unity Console.
This gives you the flexibility to track errors through Unity’s native logging system — or keep things fully contained in the Inspector UI for a cleaner workflow.
This flow lets you handle errors without leaving the component or interrupting your coding rhythm. It's fast, minimal, and always focused on the line that needs attention.