Unity Development Guide

SkillAI & models

Unity Engine integration skill for project setup, C# scripting, scene management, prefab creation, and editor automation. Enables LLMs to interact with Unity Editor through MCP servers for asset manipulation, script generation, and automated workflows.

Use Unity Development Guide in Claude, ChatGPT or Ahel Desktop

Free. Sign in, add Unity Development Guide and connect your AI. About a minute.

Also: Claude Code · Cursor · Codex

Then ask your AI: use the Unity Development Guide skill

Details

Instructions available. Your AI can read the instructions. Execution depends on the setup they require.

Add Ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.

Unity Development GuideStart free

What this skill tells your AI

The instructions your AI receives, as published by a5c-ai/babysitter in library/specializations/game-development/skills/unity-development/SKILL.md and read by Ahel’s review.

A comprehensive guide for Unity development. This skill serves as always-referenced parent skill, providing common patterns and tool selection guidance.

Architecture Patterns

Fail-Fast Principle

Do not write null checks. Use objects directly when their existence is assumed.

// NG: Forbidden pattern
if (component != null) { component.DoSomething(); }
if (gameObject != null) { gameObject.SetActive(false); }
if (service != null) { service.Execute(); }

// OK: Correct pattern - direct usage
GetComponent<Rigidbody>().velocity = Vector3.zero;
GameService.Initialize();
target.position = Vector3.zero;

Applies to:

  • Null check after GetComponent<T>()
  • Null check after Find*()
  • Null check after [Inject]

No GetComponent in Update

GetComponent every frame causes GC allocation and performance degradation. Cache in Awake.

// NG: GC allocation every frame
void Update()
{
    GetComponent<Rigidbody>().velocity = input;
}

// OK: Cache in Awake
private Rigidbody _rb;

void Awake()
{
    _rb = GetComponent<Rigidbody>();
}

void Update()
{
    _rb.velocity = input;
}

UniTask Patterns

Use UniTask instead of coroutines. async void is forbidden.

using Cysharp.Threading.Tasks;

// NG: async void
async void Start()
{
    await DoWorkAsync();
}

// OK: UniTaskVoid + destroyCancellationToken
async UniTaskVoid Start()
{
    await DoWorkAsync(destroyCancellationToken);
}

// OK: When return value is needed
async UniTask<int> CalculateAsync(CancellationToken ct)
{
    await UniTask.Delay(1000, cancellationToken: ct);
    return 42;
}

Best Practices:

  • Use destroyCancellationToken for auto-cancel on GameObject destruction
  • UniTask.Delay > Task.Delay (zero allocation)
  • UniTask.WhenAll for parallel execution

VContainer DI

Use VContainer for dependency injection. Constructor injection recommended.

// Interface definition
public interface IPlayerService
{
    void Initialize();
}

// Implementation class
public class PlayerService : IPlayerService
{
    public void Initialize() { /* ... */ }
}

// Consumer (MonoBehaviour)
public class GameManager : MonoBehaviour
{
    [Inject] private readonly IPlayerService _playerService;

    void Start()
    {
        _playerService.Initialize();
    }
}

// LifetimeScope configuration
public class GameLifetimeScope : LifetimeScope
{
    protected override void Configure(IContainerBuilder builder)
    {
        builder.Register<IPlayerService, PlayerService>(Lifetime.Singleton);
        builder.RegisterComponentInHierarchy<GameManager>();
    }
}

Lifetime Selection:

  • Lifetime.Singleton - One instance for entire app
  • Lifetime.Scoped - One instance per scene
  • Lifetime.Transient - New instance each time

MCP Tool Categories

C# Code Editing

ToolPurposeUsage Condition
edit_snippetLightweight editDiff within 80 characters
edit_structuredStructured editMethod body replacement, member addition
get_symbolsSymbol listRequired before editing
find_symbolSymbol searchFind symbol by name
find_refsReference searchBefore refactoring
readRead codeCheck file contents
searchPattern searchRegex search
create_classCreate classNew file
rename_symbolRenameProject-wide
remove_symbolRemove symbolDelete unused code

Scene & GameObject

ToolPurpose
get_hierarchyGet hierarchy
create_gameobjectCreate GameObject
modify_gameobjectModify GameObject
delete_gameobjectDelete GameObject
find_gameobjectFind GameObject
add_componentAdd component
modify_componentModify component
remove_componentRemove component
list_componentsList components

Asset Management

ToolPurpose
create_prefabCreate prefab
modify_prefabModify prefab
instantiate_prefabInstantiate prefab
create_materialCreate material
modify_materialModify material
manage_asset_databaseAsset operations
addressables_manageAddressables management

PlayMode & Testing

ToolPurpose
play_gameStart PlayMode
stop_gameStop PlayMode
pause_gamePause
input_keyboardKeyboard input
input_mouseMouse input
input_gamepadGamepad input
capture_screenshotScreenshot
run_testsRun tests

UI Systems

SystemPurposeDetail Skill
uGUIGame UI (Canvas/EventSystem)unity-game-ugui-design
UI ToolkitModern UI (Runtime/Editor)unity-game-ui-toolkit-design
IMGUIEditor extensions onlyunity-editor-imgui-design

Composite Workflow Examples

Example 1: Scene Transition with UI Button

Required operations: UI creation + Scene management + C# script

// 1. Create button GameObject
mcp__unity-mcp-server__create_gameobject({
  name: "StartButton",
  parentPath: "/Canvas"
})

// 2. Add Button component
mcp__unity-mcp-server__add_component({
  gameObjectPath: "/Canvas/StartButton",
  componentType: "Button"
})

// 3. Create click handler script
mcp__unity-mcp-server__create_class({
  path: "Assets/Scripts/UI/StartButtonHandler.cs",
  className: "StartButtonHandler",
  baseType: "MonoBehaviour",
  namespace: "Game.UI"
})

// 4. Add OnClick implementation
mcp__unity-mcp-server__edit_structured({
  path: "Assets/Scripts/UI/StartButtonHandler.cs",
  symbolName: "StartButtonHandler",
  operation: "insert_after",
  newText: `
    public void OnStartClicked()
    {
        SceneManager.LoadScene("GameScene");
    }
`
})

Example 2: Create Enemy Character

Required operations: GameObject + Components + C# script + Prefab

// 1. Create enemy GameObject
mcp__unity-mcp-server__create_gameobject({
  name: "Enemy",
  primitiveType: "capsule",
  position: { x: 0, y: 1, z: 0 }
})

// 2. Add components
mcp__unity-mcp-server__add_component({
  gameObjectPath: "/Enemy",
  componentType: "Rigidbody"
})

// 3. Create enemy script
mcp__unity-mcp-server__create_class({
  path: "Assets/Scripts/Enemies/EnemyController.cs",
  className: "EnemyController",
  baseType: "MonoBehaviour"
})

// 4. Add AI implementation
mcp__unity-mcp-server__edit_structured({
  path: "Assets/Scripts/Enemies/EnemyController.cs",
  symbolName: "EnemyController",
  operation: "insert_after",
  newText: `
    [SerializeField] private float _speed = 3f;
    private Transform _target;

    void Update()
    {
        if (_target != null)
            transform.position = Vector3.MoveTowards(
                transform.position,
                _target.position,
                _speed * Time.deltaTime
            );
    }
`
})

// 5. Convert to prefab
mcp__unity-mcp-server__create_prefab({
  gameObjectPath: "/Enemy",
  prefabPath: "Assets/Prefabs/Enemies/Enemy.prefab"
})

Example 3: PlayMode Testing

Required operations: Test creation + PlayMode control + Input simulation

// 1. Create test class
mcp__unity-mcp-server__create_class({
  path: "Assets/Tests/PlayMode/PlayerMovementTests.cs",
  className: "PlayerMovementTests",
  namespace: "Tests.PlayMode",
  usings: "NUnit.Framework,UnityEngine.TestTools,System.Collections"
})

// 2. Add PlayMode test implementation
mcp__unity-mcp-server__edit_structured({
  path: "Assets/Tests/PlayMode/PlayerMovementTests.cs",
  symbolName: "PlayerMovementTests",
  operation: "insert_after",
  newText: `
    [UnityTest]
    public IEnumerator Player_MovesForward_WhenWPressed()
    {
        var player = Object.FindObjectOfType<PlayerController>();
        var startPos = player.transform.position;

        yield return null;

        // Simulate W key input
        // Use input_keyboard tool during test execution

        yield return new WaitForSeconds(0.5f);

        Assert.Greater(player.transform.position.z, startPos.z);
    }
`
})

// 3. Run tests
mcp__unity-mcp-server__run_tests({
  testMode: "PlayMode",
  filter: "PlayerMovementTests"
})

Child Skill Reference

Refer to the following child skills when detailed implementation patterns are needed:

SkillPurposeWhen to Reference
unity-csharp-editingC# editing, TDD, refactoringDuring code editing
unity-scene-managementScene & GameObject operationsDuring scene construction
unity-asset-managementPrefabs, materials, AddressablesDuring asset management
unity-playmode-testingPlayMode, input simulationDuring test execution
unity-game-ugui-designuGUI (Canvas/EventSystem)During game UI implementation
unity-game-ui-toolkit-designUI Toolkit (Runtime)During modern UI implementation
unity-editor-imgui-designIMGUI (EditorWindow/Inspector)During editor extension

Quick Decision Tree

Unity Development Task
├─ Need code editing?
│   ├─ YES → edit_snippet / edit_structured
│   │         Details: unity-csharp-editing
│   └─ NO → Next
├─ Need scene/GameObject operations?
│   ├─ YES → create_gameobject / add_component
│   │         Details: unity-scene-management
│   └─ NO → Next
├─ Need asset operations?
│   ├─ YES → create_prefab / addressables_manage
│   │         Details: unity-asset-management
│   └─ NO → Next
├─ Need UI implementation?
│   ├─ Game UI → unity-game-ugui-design or unity-game-ui-toolkit-design
│   └─ Editor UI → unity-editor-imgui-design
└─ Need testing/verification?
    └─ YES → play_game / run_tests
              Details: unity-playmode-testing

Signals

GitHub stars
2k
Forks
113
Last commit
Sep 2026

Ahel recommends instead

Advanced
Item type
skill
Key
unity-development
Source
github.com/a5c-ai/babysitter