Files
2nd/10_Wiki/Topics/Backend/Unity.md
T
2026-05-10 22:08:15 +09:00

5.1 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-unity Unity 10_Wiki/Topics verified self
Unity Engine
Unity3D
Unity 6
none A 0.9 applied
game-engine
c-sharp
realtime
multiplayer
dots
2026-05-10 pending
language framework
C# Unity 6 (DOTS, Netcode for GameObjects)

Unity

매 한 줄

"매 cross-platform realtime engine 의 component 기반 scene graph + 매 C# scripting 의 ECS hybrid". 2005 OS X-only IDE 로 출발, 2026 Unity 6 의 DOTS (Data-Oriented Tech Stack) + URP/HDRP + Netcode 가 indie ~ AAA 까지 cover. 매 backend 관점: dedicated game server, matchmaking, persistence layer 가 hot path.

매 핵심

매 GameObject + Component

  • GameObject = container, MonoBehaviour 매 lifecycle hook (Awake → Start → Update → FixedUpdate → LateUpdate).
  • 매 inheritance 보다 composition 우선 — 매 RequireComponent 의 사용.

매 ECS / DOTS

  • Entity (ID) + IComponentData (struct) + SystemBase (logic). 매 Burst compiler + Job system 의 SIMD/multi-thread.
  • 100k+ entities @ 60fps 가 mobile 에서도 가능.

매 Networking

  • Netcode for GameObjects (NGO) — 매 NetworkBehaviour, NetworkVariable, ClientRpc/ServerRpc.
  • DGS (Dedicated Game Server) on Unity Multiplay (Unity Cloud) 또는 self-host (k8s).

매 응용

  1. 매 mobile/PC/console game (Genshin-style live ops 포함).
  2. 매 AR/VR (XR Interaction Toolkit, visionOS).
  3. 매 digital twin / BIM 시각화 (non-game enterprise).

💻 패턴

MonoBehaviour 기본

using UnityEngine;

public class PlayerController : MonoBehaviour
{
    [SerializeField] float speed = 5f;
    Rigidbody rb;

    void Awake() => rb = GetComponent<Rigidbody>();

    void FixedUpdate()
    {
        var input = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
        rb.MovePosition(rb.position + input * speed * Time.fixedDeltaTime);
    }
}

DOTS / ECS System

using Unity.Burst;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;

[BurstCompile]
public partial struct MoveSystem : ISystem
{
    public void OnUpdate(ref SystemState state)
    {
        float dt = SystemAPI.Time.DeltaTime;
        foreach (var (transform, vel) in SystemAPI.Query<RefRW<LocalTransform>, RefRO<Velocity>>())
            transform.ValueRW.Position += vel.ValueRO.Value * dt;
    }
}

Netcode RPC

public class PlayerNet : NetworkBehaviour
{
    [ServerRpc] public void FireServerRpc(Vector3 dir) {
        // server-authoritative damage
        SpawnProjectileClientRpc(dir);
    }
    [ClientRpc] void SpawnProjectileClientRpc(Vector3 dir) { /* visual only */ }
}

Addressables (async asset load)

var handle = Addressables.LoadAssetAsync<GameObject>("Boss/FinalBoss");
var prefab = await handle.Task;
Instantiate(prefab, spawnPoint.position, Quaternion.identity);

ScriptableObject (data-driven)

[CreateAssetMenu(menuName="Game/WeaponDef")]
public class WeaponDef : ScriptableObject {
    public int damage; public float fireRate; public AudioClip sfx;
}

UniTask (struct-based async)

async UniTaskVoid LoadScene() {
    await SceneManager.LoadSceneAsync("Boss").ToUniTask();
    await UniTask.Delay(500);
    BossUI.Show();
}

Dedicated Server build

# Linux server build via CLI
Unity -batchmode -nographics -quit \
  -buildTarget LinuxServer \
  -executeMethod Builder.BuildServer \
  -projectPath . -logFile build.log

매 결정 기준

상황 Approach
Indie 2D/3D, fast iteration MonoBehaviour + URP
10k+ units (RTS, swarm) DOTS + Burst
Authoritative multiplayer Netcode + DGS on Multiplay
Cross-platform UI tool UI Toolkit (UXML/USS)
매 cinematic Timeline + Cinemachine

기본값: MonoBehaviour + URP + Addressables. Scale 한계 도달 시 hot path 만 DOTS 로 migrate.

🔗 Graph

🤖 LLM 활용

언제: boilerplate MonoBehaviour, shader scaffolding, editor tool script, ECS conversion outline. 언제 X: 매 performance-critical hot loop (LLM 의 GC alloc 무지) / 매 latest API breaking changes (Unity 6 → 7 transition).

안티패턴

  • Update() everywhere: 매 frame 의 GetComponent / Find 호출. Cache in Awake.
  • String-based GameObject.Find: 매 fragile + slow. Use serialized refs.
  • Coroutine for heavy work: 매 main thread block. Use Job system or async.
  • Resources/ folder abuse: 매 build size bloat. Use Addressables.
  • No object pooling: 매 bullet/particle spam → GC spike. Pool everything reusable.

🧪 검증 / 중복

  • Verified (Unity 6 docs, Unite 2025 sessions).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — Unity 6 + DOTS + Netcode 패턴 정리