본문으로 건너뛰기
cccskills
무료GitHub에 공개

unity-foundations

Unity 6 core concepts and architecture guide. Use when working with GameObjects, Components, Transforms, Scenes, Prefabs, ScriptableObjects, or Unity project structure. Covers the entity-component architecture, object hierarchy, tags, layers, and project conventions. Based on Unity 6.3 LTS documentation.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구Unity
설치 방법 보기

포함된 파일(4)

  • SKILL.md14.5 KB
  • references/component-lifecycle.md7.9 KB
  • references/gameobject-api.md10.4 KB
  • references/prefabs-and-scenes.md13.7 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Unity Foundations

Core Concepts

GameObjects

GameObjects are the fundamental building blocks in Unity. Every object in a scene -- characters, props, scenery, cameras, lights -- is a GameObject. GameObjects are containers: they cannot function alone and require Components to gain functionality. Every GameObject automatically includes a Transform component that cannot be removed.

Components

Components are the functional pieces of every GameObject. Unity uses a composition-over-inheritance architecture: you build behavior by attaching multiple components to a GameObject rather than inheriting from deep class hierarchies. Each GameObject must have exactly one Transform component. Additional components (Rigidbody, Collider, MeshRenderer, custom MonoBehaviours) define what the object does.

Constraints from the docs:

  • Components must reside in the same project as their target GameObject
  • Components cannot be sourced from separate projects, unattached scripts, or uninstalled packages

Transforms

The Transform component stores position, rotation, and scale -- each relative to the parent (local coordinates) or to the world origin (world coordinates). Key points from the docs:

  • Child Transforms display values relative to their parent
  • Root GameObjects (no parent) show world coordinates
  • The physics engine assumes 1 unit = 1 meter
  • Set parent location to (0,0,0) before adding children so local coords match global coords
  • Avoid adjusting Transform Scale at runtime; model assets at real-life scale instead. Non-uniform scaling causes issues with Colliders, Lights, and Audio Sources

Scenes

Scenes are assets that contain all or part of a game or application. A default new scene includes a Camera and a directional Light. Projects can use a single scene or multiple scenes (e.g., one per level). Scene Templates serve as blueprints for creating new scenes.

Prefabs

Prefabs are reusable asset templates that store a complete GameObject configuration (all components, property values, and child GameObjects). Key features:

  • Nested Prefabs: Include prefab instances within other prefabs
  • Prefab Variants: Create predefined variations that maintain a base prefab relationship
  • Overrides: Modify components/data on specific instances without affecting the template
  • Unpacking: Convert prefab instances back to standalone GameObjects

ScriptableObjects

ScriptableObject is a serializable Unity type derived from UnityEngine.Object that serves as a data container independent of GameObjects. Unlike MonoBehaviours, ScriptableObjects exist as project-level .asset files. Primary use cases:

  • Shared data containers (reduces memory by referencing one asset instead of duplicating data across prefabs)
  • Editor tool foundations (EditorTool, EditorWindow derive from ScriptableObject)
  • Runtime configuration storage

Critical: Unity does not automatically save changes to a ScriptableObject made via script in Edit mode. You must call EditorUtility.SetDirty() after modifications.

Tags

Tags are reference identifiers assigned to GameObjects for scripting purposes. Each GameObject can have only one tag, but multiple GameObjects can share the same tag. Built-in tags: Untagged, Respawn, Finish, EditorOnly, MainCamera, Player, GameController.

  • MainCamera: The Editor caches these; Camera.main returns the first valid result
  • EditorOnly: GameObjects tagged this way are destroyed during builds
  • Tag names cannot be renamed once created

Layers

Layers separate GameObjects for selective processing including camera rendering, lighting, physics collisions, and custom code logic. Unity supports up to 32 layers. LayerMasks define which layers an API call interacts with.


Common Patterns

Creating and Accessing Components

using UnityEngine;

public class ComponentAccess : MonoBehaviour
{
    void Start()
    {
        // Get a component on this GameObject
        Rigidbody rb = GetComponent<Rigidbody>();

        // Get a component on a child GameObject
        Collider childCollider = GetComponentInChildren<Collider>();

        // Get all components of a type on this and children
        MeshRenderer[] renderers = GetComponentsInChildren<MeshRenderer>();

        // Add a component at runtime
        BoxCollider box = gameObject.AddComponent<BoxCollider>();

        // Remove a component (destroys it)
        Destroy(box);
    }
}

Finding GameObjects

using UnityEngine;

public class FindingObjects : MonoBehaviour
{
    void Start()
    {
        // Find by tag (returns first match)
        GameObject player = GameObject.FindWithTag("Player");

        // Find all with tag
        GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");

        // Find by name (slow -- avoid in Update)
        GameObject manager = GameObject.Find("GameManager");

        // Compare tags efficiently (no GC allocation)
        if (gameObject.CompareTag("Player"))
        {
            Debug.Log("This is the player");
        }
    }
}

Instantiating Prefabs

From the Unity docs example:

using UnityEngine;

public class InstantiationExample : MonoBehaviour
{
    // Reference to the prefab. Drag a prefab into this field in the Inspector.
    public GameObject myPrefab;

    void Start()
    {
        // Instantiate at position (0, 0, 0) and zero rotation.
        Instantiate(myPrefab, new Vector3(0, 0, 0), Quaternion.identity);
    }
}

Instantiating with Parent Transform

using UnityEngine;

public class SpawnWithParent : MonoBehaviour
{
    public GameObject prefab;
    public Transform parentTransform;

    void SpawnChild()
    {
        // Instantiate as child of a parent transform
        GameObject instance = Instantiate(prefab, parentTransform);

        // Instantiate at specific world position under a parent
        GameObject positioned = Instantiate(
            prefab,
            new Vector3(5, 0, 0),
            Quaternion.identity,
            parentTransform
        );
    }
}

ScriptableObject Data Container

From the Unity docs:

using UnityEngine;

[CreateAssetMenu(fileName = "Data", menuName = "ScriptableObjects/SpawnData", order = 1)]
public class SpawnDataScriptableObject : ScriptableObject
{
    public GameObject prefab;
    public int count;
    public Vector3[] positions;
}
using UnityEngine;

public class SpawnManager : MonoBehaviour
{
    public SpawnDataScriptableObject spawnData;

    void Start()
    {
        for (int i = 0; i < spawnData.count; i++)
        {
            Instantiate(spawnData.prefab, spawnData.positions[i], Quaternion.identity);
        }
    }
}

Scene Management

using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneLoader : MonoBehaviour
{
    void Start()
    {
        // Subscribe to scene loaded event
        SceneManager.sceneLoaded += OnSceneLoaded;
    }

    void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        Debug.Log("Loaded: " + scene.name);
    }

    public void LoadLevel(string sceneName)
    {
        // Load scene by name (replaces current)
        SceneManager.LoadScene(sceneName);
    }

    public void LoadAdditive(string sceneName)
    {
        // Load scene additively (keeps current scenes)
        SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
    }

    public void UnloadLevel(string sceneName)
    {
        SceneManager.UnloadSceneAsync(sceneName);
    }

    public void GetSceneInfo()
    {
        Scene active = SceneManager.GetActiveScene();
        Debug.Log("Active scene: " + active.name);
        Debug.Log("Loaded scene count: " + SceneManager.loadedSceneCount);
    }
}

Tag-Based Spawning

From the Unity docs example:

using UnityEngine;

public class RespawnSystem : MonoBehaviour
{
    public GameObject respawnPrefab;
    private GameObject respawn;

    void Update()
    {
        if (respawn == null)
            respawn = GameObject.FindWithTag("Respawn");

        if (respawn != null)
        {
            Instantiate(respawnPrefab, respawn.transform.position,
                respawn.transform.rotation);
        }
    }
}

Activating and Deactivating GameObjects

using UnityEngine;

public class ToggleVisibility : MonoBehaviour
{
    public GameObject target;

    public void Toggle()
    {
        // SetActive controls whether the GameObject is active
        target.SetActive(!target.activeSelf);

        // activeSelf: this object's own active state
        // activeInHierarchy: effective state (considers parent chain)
        Debug.Log("Self: " + target.activeSelf);
        Debug.Log("InHierarchy: " + target.activeInHierarchy);
    }
}

Layer Masks for Raycasting

using UnityEngine;

public class LayerRaycast : MonoBehaviour
{
    void Update()
    {
        // Create a layer mask for layer named "Ground"
        int groundLayer = LayerMask.NameToLayer("Ground");
        int layerMask = 1 << groundLayer;

        // Raycast only against the Ground layer
        if (Physics.Raycast(transform.position, Vector3.down, out RaycastHit hit, 100f, layerMask))
        {
            Debug.Log("Hit ground at: " + hit.point);
        }

        // Use GetMask for multiple layers
        int combinedMask = LayerMask.GetMask("Ground", "Water");
        Physics.Raycast(transform.position, Vector3.forward, 50f, combinedMask);
    }
}

Anti-Patterns

1. Using GameObject.Find in Update

// BAD: Find is expensive -- runs every frame with string lookup
void Update()
{
    GameObject player = GameObject.Find("Player"); // Avoid!
}

// GOOD: Cache the reference
private GameObject player;
void Start()
{
    player = GameObject.FindWithTag("Player");
}

2. Non-Uniform Transform Scale

From the docs: "Don't adjust the Scale of your GameObject in the Transform component." Non-uniform scaling (e.g., 2, 4, 2) causes:

  • Colliders, Lights, Audio Sources to behave incorrectly
  • Rotated children to appear skewed
  • Performance degradation when instantiating scaled objects

Model assets at real-life scale instead.

3. Duplicating Data Across Prefabs Instead of Using ScriptableObjects

// BAD: Every prefab instance duplicates this data
public class EnemyStats : MonoBehaviour
{
    public int health = 100;
    public float speed = 5f;
    public string enemyName = "Goblin";
}

// GOOD: Use a ScriptableObject -- one asset, many references
[CreateAssetMenu(menuName = "ScriptableObjects/EnemyConfig")]
public class EnemyConfig : ScriptableObject
{
    public int health = 100;
    public float speed = 5f;
    public string enemyName = "Goblin";
}

public class Enemy : MonoBehaviour
{
    public EnemyConfig config; // All instances share the same asset
}

4. Forgetting EditorUtility.SetDirty for ScriptableObject Changes

// BAD: Changes in Edit mode won't persist
settings.value += 10;

// GOOD: Mark asset dirty so Unity saves it
settings.value += 10;
EditorUtility.SetDirty(settings);

5. String-Based Tag Comparison

// BAD: Allocates a new string for comparison (GC pressure)
if (gameObject.tag == "Player") { }

// GOOD: CompareTag avoids allocation
if (gameObject.CompareTag("Player")) { }

6. Ignoring Parent-Child Transform Relationships

Set a parent's location to (0,0,0) before adding children. Otherwise child local coordinates will not match global coordinates, causing confusion when positioning objects.


Key API Quick Reference

APIDescriptionNotes
GetComponent<T>()Get component on same GameObjectReturns null if not found
GetComponentInChildren<T>()Get component on self or childrenSearches depth-first
GetComponentsInChildren<T>()Get all matching components in hierarchyReturns array
AddComponent<T>()Attach new component at runtimeReturns the new component
Destroy(obj)Destroy a GameObject or ComponentDeferred to end of frame
Instantiate(prefab, pos, rot)Clone a prefab at position/rotationReturns the clone
GameObject.FindWithTag(tag)Find first active GO with tagReturns null if none
GameObject.FindGameObjectsWithTag(tag)Find all active GOs with tagReturns array
GameObject.Find(name)Find by name (expensive)Avoid in Update loops
gameObject.SetActive(bool)Activate/deactivateDisables all components
gameObject.CompareTag(tag)Tag comparison without GC allocPreferred over == tag
SceneManager.LoadScene(name)Load scene (replaces current)Must be in Build Settings
SceneManager.LoadSceneAsync(name, mode)Async scene loadingAdditive or Single mode
SceneManager.UnloadSceneAsync(name)Unload a loaded sceneReturns AsyncOperation
SceneManager.GetActiveScene()Get current active sceneReturns Scene struct
LayerMask.NameToLayer(name)Get layer index from nameReturns int
LayerMask.GetMask(names)Get combined mask from layer namesParams string array
Camera.mainGet MainCamera-tagged cameraCached by Unity

Related Skills

  • unity-scripting -- C# scripting patterns, MonoBehaviour lifecycle, coroutines, events
  • unity-physics -- Rigidbody, Colliders, physics layers, raycasting, triggers
  • unity-editor-tools -- Custom inspectors, editor windows, gizmos, build pipeline

Additional Resources

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

adopt

무료

Brownfield onboarding — audits existing project artifacts for template format compliance (not just existence), classifies gaps by impact, and produces a numbered migration plan. Run this when joining an in-progress project or upgrading from an older template version. Distinct from /project-stage-detect (which checks what exists) — this checks whether what exists will actually work with the template's skills.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

IdoCohen560/claude-unity-game-studio222026년 7월 8일 업데이트

Creates an Architecture Decision Record (ADR) documenting a significant technical decision, its context, alternatives considered, and consequences. Every major technical choice should have an ADR.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

IdoCohen560/claude-unity-game-studio222026년 7월 8일 업데이트

Validates completeness and consistency of the project architecture against all GDDs. Builds a traceability matrix mapping every GDD technical requirement to ADRs, identifies coverage gaps, detects cross-ADR conflicts, verifies engine compatibility consistency across all decisions, and produces a PASS/CONCERNS/FAIL verdict. The architecture equivalent of /design-review.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

IdoCohen560/claude-unity-game-studio222026년 7월 8일 업데이트

art-bible

무료

Guided, section-by-section Art Bible authoring. Creates the visual identity specification that gates all asset production. Run after /brainstorm is approved and before /map-systems or any GDD authoring begins.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

IdoCohen560/claude-unity-game-studio222026년 7월 8일 업데이트

Audits game assets for compliance with naming conventions, file size budgets, format standards, and pipeline requirements. Identifies orphaned assets, missing references, and standard violations.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

IdoCohen560/claude-unity-game-studio222026년 7월 8일 업데이트

Generate per-asset visual specifications and AI generation prompts from GDDs, level docs, or character profiles. Produces structured spec files and updates the master asset manifest. Run after art bible and GDD/level design are approved, before production begins.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

IdoCohen560/claude-unity-game-studio222026년 7월 8일 업데이트

IdoCohen560의 스킬 모두 보기

이 스킬의 문제 신고