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

uw-network-setup

Generates networking boilerplate adapted to the project's chosen networking package (NGO, Mirror, Photon). Use when setting up multiplayer systems, syncing state, writing RPCs, building lobbies, or designing an authority matrix. Triggers on requests like "add multiplayer", "sync player health", "create an RPC", "set up lobbies", "make this networked", "add co-op", "replicate this across clients", "spawn networked objects", "handle player disconnect", "create a matchmaking system", or any task involving network state synchronization, remote procedure calls, or client-server architecture. Always reads ProjectConfig.yaml -> networking before generating code. If networking is "none", do NOT generate networking code.

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

설치 방법 보기

포함된 파일(4)

  • SKILL.md8.4 KB
  • references/mirror.md616 B
  • references/ngo.md846 B
  • references/photon.md688 B

SKILL.md(원문)

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

Network Setup

Generate networking code adapted to the project's chosen package.

Before You Start

  1. Read docs/ProjectConfig.yaml for:
    • networking — the package name ("ngo", "mirror", "photon", or "none"). If "none", stop — do not generate networking code.
    • architecture_pattern — "so-first" or "di-first" (affects how network services are wired).
    • mcp.unity_mcp — if true, call refresh_unity after creating files.
  2. Read docs/TDD_Template.md for the authority matrix (who owns what data).
  3. Read docs/CODING_STANDARDS.md for async patterns (Awaitable + CancellationToken) and class structure.
  4. Read docs/NAMING_CONVENTIONS.md for file/class naming.

Package Quick Reference

Each package has a detailed reference file. Read the relevant one before generating code:

  • NGO (Netcode for GameObjects): references/ngo.md — Unity's first-party solution. Uses NetworkVariable, [Rpc] attributes.
  • Mirror: references/mirror.md — Community open-source. Uses [SyncVar], [Command]/[ClientRpc].
  • Photon (PUN2/Fusion): references/photon.md — Cloud-hosted. Uses IPunObservable, [PunRPC].

Core Patterns (All Packages)

State Synchronization

Every package has a mechanism for syncing state from server/host to clients. The pattern is the same — only the syntax differs.

PackageSync MechanismChange CallbackExample
NGONetworkVariable<T>.OnValueChanged += handler_health.OnValueChanged += OnHealthChanged;
Mirror[SyncVar(hook = nameof(...))]Hook method[SyncVar(hook = nameof(OnHealthChanged))]
PhotonIPunObservableOnPhotonSerializeViewManual read/write in serialize callback

Remote Procedure Calls (RPCs)

RPCs let clients request actions on the server, or the server push updates to clients.

NGO:

[Rpc(SendTo.Server)]
public void RequestDamageServerRpc(int amount)
{
    // Runs on server — validate before applying
    if (amount < 0 || amount > MAX_DAMAGE) return;
    _health.Value = Mathf.Max(0, _health.Value - amount);
}

[Rpc(SendTo.ClientsAndHost)]
public void PlayHitEffectClientRpc()
{
    // Runs on all clients — visual/audio only, no game state
}

Mirror:

[Command]
public void CmdRequestDamage(int amount)
{
    if (amount < 0 || amount > MAX_DAMAGE) return;
    _health = Mathf.Max(0, _health - amount);
    RpcPlayHitEffect();
}

[ClientRpc]
public void RpcPlayHitEffect()
{
    // Visual/audio feedback on all clients
}

Photon:

public void RequestDamage(int amount)
{
    photonView.RPC(nameof(RpcTakeDamage), RpcTarget.MasterClient, amount);
}

[PunRPC]
private void RpcTakeDamage(int amount, PhotonMessageInfo info)
{
    if (!PhotonNetwork.IsMasterClient) return;
    if (amount < 0 || amount > MAX_DAMAGE) return;
    _health = Mathf.Max(0, _health - amount);
}

Network Object Spawning

Spawning networked objects follows the same principle: only the server/host creates the authoritative instance, and the network layer replicates it to clients.

NGO:

// Server only — spawn a networked prefab
var instance = Instantiate(_projectilePrefab, spawnPoint.position, spawnPoint.rotation);
instance.GetComponent<NetworkObject>().Spawn();

Mirror:

// Server only
var instance = Instantiate(_projectilePrefab, spawnPoint.position, spawnPoint.rotation);
NetworkServer.Spawn(instance);

Photon:

// Room owner or any client (Photon handles ownership)
PhotonNetwork.Instantiate(_projectilePrefabName, spawnPoint.position, spawnPoint.rotation);

Authority Matrix Template

Define who owns, reads, and writes each piece of networked state. Fill this in before writing code — it prevents authority bugs.

EntityOwnerReadWriteSync MethodValidation
Player HealthServerEveryoneServerNetworkVariable / SyncVarClamp 0-max, rate limit
Player PositionServerEveryoneServerNetworkTransformSpeed cap, teleport check
Player InputClientServerOwnerRPC (client -> server)Sanitize on server
Chat MessagesClientEveryoneOwnerRPCLength limit, rate limit
Game TimerServerEveryoneServerNetworkVariable / SyncVarServer-authoritative only
InventoryServerOwnerServerRPC + NetworkVariableValidate item exists

Abstraction Layer (Optional)

When the project might switch networking packages later, or when using DI (architecture_pattern: "di-first"), wrap networking behind an interface:

public interface INetworkService
{
    bool IsServer { get; }
    bool IsClient { get; }
    bool IsConnected { get; }
    void SendToServer<T>(T message) where T : struct;
    void SendToClients<T>(T message) where T : struct;
}

Register the concrete implementation in the DI container (see uw-dependency-injection). Game systems depend on INetworkService, not the package directly. This makes testing easier too — mock the interface in EditMode tests.

Custom Type Serialization

When syncing custom structs over the network, each package has its own serialization approach:

NGO — implement INetworkSerializable:

public struct DamageEvent : INetworkSerializable
{
    public int Amount;
    public ulong AttackerId;

    public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
    {
        serializer.SerializeValue(ref Amount);
        serializer.SerializeValue(ref AttackerId);
    }
}

Mirror — implement custom Reader/Writer extensions or use [SyncVar] with supported types.

Photon — serialize manually in OnPhotonSerializeView or register custom types with PhotonPeer.RegisterType.

Client Prediction & Lag Compensation

For responsive gameplay (especially movement and shooting), client-side prediction avoids waiting for server confirmation:

  1. Client predicts — apply input locally immediately.
  2. Server validates — process the input authoritatively, send correction.
  3. Client reconciles — if server state differs from prediction, snap or interpolate to correct position.

This is complex. NGO has built-in NetworkTransform prediction. Mirror has community prediction examples. Photon Fusion has built-in state authority with rollback. For custom prediction, start with movement only and expand from there.

After Setup

  • DI integration: If architecture_pattern: "di-first", use uw-dependency-injection to register network services in the container.
  • Write tests: Use uw-unity-test-runner — test game logic in EditMode by mocking INetworkService. Test actual networking in PlayMode.
  • Authority matrix: Fill in docs/TDD_Template.md with the authority matrix before writing any sync code.

Rules

  • Server-authoritative unless docs/TDD_Template.md explicitly specifies peer-to-peer.
  • Never trust client input — always validate on the server (bounds check, rate limit, permission check).
  • Cache NetworkBehaviour references in Awake() or OnNetworkSpawn() — never GetComponent in Update.
  • Use [SerializeField] private for prefab references and configuration — never public fields.
  • Check the package version in ProjectConfig.yaml before using any API — breaking changes happen between major versions.
  • Use Awaitable with CancellationToken for async network operations (connection, scene loading) per CODING_STANDARDS.md.
  • All networking code must live inside an .asmdef.
  • If ProjectConfig.yaml -> mcp.unity_mcp is true, call refresh_unity after creating files.

리뷰

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

댓글

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

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

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. 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의 스킬 모두 보기

이 스킬의 문제 신고