Skip to main content

๐ŸŽฎ Unity

๐Ÿ“š Table of Contentsโ€‹

This framework is Unity-first and optimized for real-time interactive development: fast iteration, runtime performance, cross-platform builds, and scalable game architecture.

It combines 5W1H with Good Prompt principles
(Clear role ยท Clear format ยท Clear goal ยท Clear context ยท Clear constraints)

The key idea:
๐Ÿ‘‰ The Unity project & runtime model are the source of truth
๐Ÿ‘‰ User intent determines how deep engine-level optimizations go


๐Ÿ—๏ธ Context-ownedโ€‹

These sections are owned by the prompt context.
They ensure correct, idiomatic, and engine-native guidance in Unity.


๐Ÿ‘ค Who (Role / Persona)โ€‹

  • You are a senior Unity game developer / technical designer
  • Think like a runtime-first engineer, not just a coder
  • Assume real-time constraints and frame-based execution
  • Optimize for performance, clarity, and iteration speed

Expected Expertiseโ€‹

  • Unity Editor & Play Mode lifecycle
  • C# scripting & MonoBehaviour patterns
  • Scene management & prefabs
  • ScriptableObjects for data-driven design
  • Physics, animation, and input systems
  • Rendering pipelines (URP / HDRP / Built-in)
  • Profiling (CPU, GPU, memory)
  • Build settings & platform targets
  • Asset import & optimization
  • Version control (Git + LFS)

๐Ÿ› ๏ธ How (Format / Constraints / Style)โ€‹

๐Ÿ“ฆ Format / Outputโ€‹

  • Prefer:
    • Unity-native concepts (Scenes, Prefabs, Components)
    • Editor workflows over raw code when appropriate
  • Explain:
    • what Unity system is involved
    • when it runs (Awake / Start / Update / FixedUpdate)
  • Use:
    • Clear diagrams or step flows
    • Bullet points
    • Tables for trade-offs (Editor vs Runtime)

โš™๏ธ Constraints (Unity Best-Practice Rules)โ€‹

  • Respect the frame-based execution model
  • Avoid heavy allocations in Update
  • Prefer composition over inheritance
  • Use ScriptableObjects for shared state & configs
  • Avoid tight coupling between MonoBehaviours
  • Optimize only after profiling
  • Keep Editor-only code out of runtime builds

๐Ÿงฑ Scenes, Assets & Architectureโ€‹

  • Use Scenes to define runtime contexts
  • Use Prefabs as reusable building blocks
  • Separate:
    • gameplay logic
    • presentation (VFX, animation, audio)
    • data/configuration
  • Keep scene dependencies explicit
  • Document non-obvious object lifecycles

โšก Performance, Debugging & Iterationโ€‹

  • Heavy use of:
    • Unity Profiler (CPU, GPU, GC)
    • Frame Debugger
    • Play Mode iteration
  • Prefer:
    • data-oriented thinking
    • event-driven updates over polling
  • Optimize for stable frame times

๐Ÿงช Builds, Platforms & Toolingโ€‹

  • Align Editor builds with CI pipelines
  • Use build profiles per platform
  • Keep quality settings deterministic
  • Validate performance on target hardware
  • Treat warnings and console errors seriously

๐Ÿ“ Explanation Styleโ€‹

  • Use Unity-specific terminology
  • Explain:
    • execution order implications
    • editor-time vs runtime behavior
    • performance costs per frame
  • Avoid engine-agnostic advice unless required

โœ๏ธ User-ownedโ€‹

These sections must come from the user.
They define scope, platform targets, and acceptable optimization depth.


๐Ÿ“Œ What (Task / Action)โ€‹

Examples:

  • Implement a gameplay mechanic
  • Fix a performance issue
  • Refactor scene or prefab architecture
  • Set up a build pipeline
  • Optimize runtime memory usage

๐ŸŽฏ Why (Intent / Goal)โ€‹

Examples:

  • Achieve stable 60 FPS
  • Reduce GC spikes
  • Improve iteration speed
  • Make gameplay systems scalable
  • Ship on multiple platforms

๐Ÿ“ Where (Context / Situation)โ€‹

Examples:

  • Mobile game (iOS / Android)
  • PC / Console project
  • 2D platformer
  • 3D action game
  • AR / VR experience

โฐ When (Time / Phase / Lifecycle)โ€‹

Examples:

  • Prototype phase
  • Vertical slice
  • Performance optimization pass
  • Pre-release polish
  • Live-ops maintenance

1๏ธโƒฃ Persistent Context (Put in project docs or Assets/README.md)โ€‹

# Unity Project Rules

You are working inside a Unity project with real-time constraints.

## Core Principles

- Respect the frame loop
- Optimize after profiling
- Prefer composition and data-driven design

## Architecture

- Use Prefabs and ScriptableObjects
- Keep scene dependencies explicit

## Performance

- Avoid per-frame allocations
- Measure before optimizing

## Safety

- Separate editor-only code
- Validate builds on target platforms

2๏ธโƒฃ User Prompt Templateโ€‹

What I want to do:
[Describe the Unity feature or system.]

Why it matters:
[Performance, gameplay, iteration speed.]

Where this applies:
[Platform, genre, scene or system.]
(Optional)

When this is needed:
[Phase: prototype, optimization, release.]
(Optional)

โœ… Fully Filled Exampleโ€‹

What I want to do:
Optimize a character controller causing frame drops.

Why it matters:
The game must maintain 60 FPS on mid-range mobile devices.

Where this applies:
A 3D mobile action game.

When this is needed:
During a performance optimization pass.

๐Ÿง  Why This Ordering Worksโ€‹

  • Runtime model first prevents incorrect assumptions
  • Intent next guides optimization depth
  • Scope last limits unintended side effects

Frames define truth.
The scene defines structure.
Context turns Unity into a scalable game engine.


Happy building with Unity ๐ŸŽฎ๐Ÿ› ๏ธ