Token导航 LogoToken导航TokenDH.com
研究检索只读github未标认证来源可访问clear审计通过

unity-fundamentalsUnity fundamentals 搜索

Agent Skill

unity-fundamentals 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

3,382

周安装

86

GitHub Stars

3

下载量

934
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:unity-fundamentals(Unity fundamentals 搜索)
来源仓库:https://github.com/cryptorabea/claude_unity_dev_plugin
仓库路径:skills/unity-fundamentals
安装命令:
npx skills add https://github.com/cryptorabea/claude_unity_dev_plugin --skill 'Unity Fundamentals'
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/cryptorabea/claude_unity_dev_plugin --skill 'Unity Fundamentals'

简介

用于 Unity 基础概念和开发流程的信息查找、检索和筛选,适合在 Codex、Claude、Cursor、Gemini CLI 中快速定位基础资料。

  • 适用于需要根据关键词或学习场景定位候选结果时使用。
  • 通过 npx skills add 命令从 GitHub 仓库安装并使用。
  • 安装前建议确认权限范围和维护状态,避免触发不必要的联网或文件操作。
  • unity-fundamentals 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Unity Fundamentals

Comprehensive guidance on Unity's core systems, MonoBehaviour lifecycle, serialization, component architecture, and prefab workflows.

Overview

Unity development centers around MonoBehaviour components, the Component pattern, and a specific lifecycle of callback methods. Understanding these fundamentals is critical for writing correct, performant Unity code. This skill covers:

  • MonoBehaviour lifecycle methods and their proper usage
  • Serialization system and Inspector integration
  • Component-based architecture and GetComponent patterns
  • Prefab workflows and best practices

MonoBehaviour Lifecycle

Unity calls specific methods on MonoBehaviour scripts in a predetermined order. Using the wrong method leads to bugs, null references, and poor performance.

Initialization Methods

Awake()

Called when the script instance loads, before any Start() calls. Use for initializing this object's state.

private void Awake()
{
    // Cache component references on THIS GameObject
    rigidbody = GetComponent<Rigidbody>();
    animator = GetComponent<Animator>();

    // Initialize private state
    currentHealth = maxHealth;
    inventory = new List<Item>();

    // DON'T reference other objects - they may not be initialized yet
}

Use Awake() for:

  • Caching component references
  • Initializing private fields
  • Setting up internal state
  • Creating singletons/managers

Don't use Awake() for:

  • Referencing other GameObjects (use Start instead)
  • Performing operations that depend on other scripts being ready

Start()

Called before the first Update(), after all Awake() calls complete. Use for setup that references other objects.

private void Start()
{
    // Safe to reference other GameObjects - they're initialized
    playerTransform = GameObject.FindWithTag("Player").transform;
    gameManager = FindObjectOfType<GameManager>();

    // Register with managers or systems
    GameManager.Instance.RegisterEnemy(this);

    // Perform initialization that depends on other components
    SetupWeapon(gameManager.GetStartingWeapon());
}

Use Start() for:

  • Finding and referencing other GameObjects
  • Calling initialization methods on other components
  • Registering with managers or systems
  • Setup that depends on scene being fully initialized

Common Pattern:

private Camera mainCamera;  // Cache in Awake
private Transform target;    // Find in Start

private void Awake()
{
    mainCamera = Camera.main;  // Cache expensive lookup
}

private void Start()
{
    target = GameObject.FindWithTag("Target").transform;  // Find after scene loads
}

OnEnable() / OnDisable()

Called when GameObject becomes active/inactive. Use for subscribing/unsubscribing from events.

private void OnEnable()
{
    // Subscribe to events
    GameEvents.OnPlayerDied += HandlePlayerDeath;
    InputManager.OnJumpPressed += HandleJump;

    // Re-enable functionality
    StartCoroutine(SpawnEnemies());
}

private void OnDisable()
{
    // Unsubscribe from events (prevents memory leaks!)
    GameEvents.OnPlayerDied -= HandlePlayerDeath;
    InputManager.OnJumpPressed -= HandleJump;

    // Clean up temporary state
    StopAllCoroutines();
}

Critical: Always unsubscribe in OnDisable() to prevent memory leaks.

Update Methods

Update()

Called every frame. Use sparingly - performance critical.

private void Update()
{
    // Input handling
    if (Input.GetKeyDown(KeyCode.Space))
        Jump();

    // Frame-dependent logic
    UpdateUI();

    // AVOID expensive operations here
    // DON'T call GetComponent every frame
    // DON'T use Find methods
}

Avoid Update() when possible. Prefer event-driven approaches.

FixedUpdate()

Called at fixed timestep (default 50 FPS). Use for physics operations only.

private void FixedUpdate()
{
    // Physics operations
    rigidbody.AddForce(moveDirection * moveSpeed);

    // Physics-based movement
    rigidbody.MovePosition(transform.position + velocity * Time.fixedDeltaTime);

    // DON'T handle input here (use Update)
    // DON'T update UI here (use Update or LateUpdate)
}

Rule: If it touches Rigidbody or physics, use FixedUpdate(). Everything else uses Update() or event-driven approaches.

LateUpdate()

Called after all Update() calls. Use for camera follow and final adjustments.

private void LateUpdate()
{
    // Camera follow (after player moved in Update)
    transform.position = target.position + offset;

    // Final position adjustments
    ClampToBounds();

    // UI updates that depend on world state
    UpdateHealthBar();
}

Destruction Methods

OnDestroy()

Called when GameObject is destroyed. Use for final cleanup.

private void OnDestroy()
{
    // Unsubscribe from static events
    GameEvents.OnPlayerDied -= HandlePlayerDeath;

    // Release resources
    if (texture != null)
        Destroy(texture);

    // Notify other systems
    GameManager.Instance.UnregisterEnemy(this);
}

Lifecycle Order Summary

  1. Awake() - Initialize self
  2. OnEnable() - Subscribe to events
  3. Start() - Reference others, final setup
  4. FixedUpdate() - Physics (50 FPS)
  5. Update() - Per-frame logic (variable FPS)
  6. LateUpdate() - Camera, final adjustments
  7. OnDisable() - Unsubscribe from events
  8. OnDestroy() - Final cleanup

Serialization System

Unity's serialization system controls what appears in the Inspector and how data persists.

Serialized Fields

Make private fields editable in Inspector:

[SerializeField] private int maxHealth = 100;
[SerializeField] private float moveSpeed = 5f;
[SerializeField] private GameObject prefab;

Benefits:

  • Keeps encapsulation (private access)
  • Inspector editing
  • Prefab/scene data persistence

Best Practice: Prefer [SerializeField] private over public fields.

Header and Tooltip

Organize Inspector sections:

[Header("Movement Settings")]
[Tooltip("Maximum movement speed in units per second")]
[SerializeField] private float moveSpeed = 5f;

[Tooltip("Rotation speed in degrees per second")]
[SerializeField] private float rotationSpeed = 180f;

[Header("Combat Settings")]
[SerializeField] private int attackDamage = 25;

Serialization Rules

What Unity serializes:

  • Public fields (unless [HideInInspector])
  • Private fields with [SerializeField]
  • Supported types: primitives, Unity objects, structs, arrays, Lists

What Unity doesn't serialize:

  • Properties
  • Private fields without [SerializeField]
  • Dictionaries
  • Interfaces
  • Static fields

Properties vs Serialized Fields

// DON'T expose internal state directly
public int health;  // Bad: public field

// DO use properties for controlled access
[SerializeField] private int health = 100;
public int Health
{
    get => health;
    set
    {
        health = Mathf.Clamp(value, 0, maxHealth);
        OnHealthChanged?.Invoke(health);
    }
}

Component Architecture

Unity uses the Component pattern - functionality composed from multiple components.

GetComponent Pattern

Cache references in Awake() to avoid repeated lookups:

// ❌ BAD - Repeated GetComponent calls
private void Update()
{
    GetComponent<Rigidbody>().velocity = Vector3.forward;  // Expensive!
}

// ✅ GOOD - Cache once
private Rigidbody rb;

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

private void Update()
{
    rb.velocity = Vector3.forward;  // Fast
}

Component Variations

// GetComponent<T>() - On this GameObject
rb = GetComponent<Rigidbody>();

// GetComponentInChildren<T>() - This GameObject and children
animator = GetComponentInChildren<Animator>();

// GetComponentInParent<T>() - This GameObject and parents
canvas = GetComponentInParent<Canvas>();

// GetComponents<T>() - Multiple components
Collider[] colliders = GetComponents<Collider>();

Performance: Cache all GetComponent results. Never call in Update/FixedUpdate.

Required Components

Declare component dependencies:

[RequireComponent(typeof(Rigidbody))]
[RequireComponent(typeof(Collider))]
public class PlayerMovement : MonoBehaviour
{
    private Rigidbody rb;

    private void Awake()
    {
        rb = GetComponent<Rigidbody>();  // Guaranteed to exist
    }
}

Component Communication

Direct Reference (Inspector):

[SerializeField] private HealthDisplay healthDisplay;

private void TakeDamage(int amount)
{
    health -= amount;
    healthDisplay.UpdateHealth(health);  // Direct call
}

GetComponent (Runtime):

private void OnTriggerEnter(Collider other)
{
    var health = other.GetComponent<Health>();
    if (health != null)
        health.TakeDamage(10);
}

Events (Decoupled):

public event Action<int> OnHealthChanged;

private void TakeDamage(int amount)
{
    health -= amount;
    OnHealthChanged?.Invoke(health);  // Any subscribers get notified
}

Prefab Workflows

Prefabs are reusable GameObject templates. Understanding prefab workflows prevents common issues.

Creating Prefabs

Drag GameObject from Hierarchy to Project window. Blue text in Hierarchy indicates prefab instance.

Prefab Instances

Changes to prefab instances:

  • Override - Changes to this instance only (bold blue)
  • Apply - Push changes to prefab asset (affects all instances)
  • Revert - Discard instance changes, match prefab

Prefab Variants

Create variations of a base prefab:

Base Prefab: Enemy
├── Variant: FastEnemy (increased speed)
├── Variant: TankEnemy (increased health)
└── Variant: FlyingEnemy (added flight)

Changes to base prefab propagate to variants.

Nested Prefabs

Prefabs can contain other prefabs:

Car Prefab
├── Wheel Prefab (x4)
├── Engine Prefab
└── Door Prefab (x4)

Edit nested prefabs independently.

Programmatic Prefab Usage

[SerializeField] private GameObject enemyPrefab;
[SerializeField] private Transform spawnPoint;

private void SpawnEnemy()
{
    // Instantiate prefab
    GameObject enemy = Instantiate(enemyPrefab, spawnPoint.position, Quaternion.identity);

    // Configure instance
    enemy.GetComponent<Enemy>().SetTarget(player);

    // Parent to container (optional)
    enemy.transform.SetParent(enemyContainer);
}

Prefab Best Practices

  1. Use prefabs for anything spawned at runtime (enemies, projectiles, UI panels)
  2. Create prefab variants instead of duplicating prefabs
  3. Apply changes carefully - affects all instances
  4. Keep prefabs in organized folders - Prefabs/Characters, Prefabs/UI, etc.
  5. Test prefab changes before applying to all instances

Common Patterns

Singleton Manager

public class GameManager : MonoBehaviour
{
    public static GameManager Instance { get; private set; }

    private void Awake()
    {
        if (Instance != null && Instance != this)
        {
            Destroy(gameObject);
            return;
        }

        Instance = this;
        DontDestroyOnLoad(gameObject);
    }
}

Object Initialization

public class Enemy : MonoBehaviour
{
    [SerializeField] private int health = 100;

    private Rigidbody rb;
    private Transform target;

    // 1. Cache components on self
    private void Awake()
    {
        rb = GetComponent<Rigidbody>();
    }

    // 2. Find external references
    private void Start()
    {
        target = GameObject.FindWithTag("Player").transform;
    }

    // 3. Subscribe to events
    private void OnEnable()
    {
        GameEvents.OnWaveComplete += HandleWaveComplete;
    }

    // 4. Unsubscribe from events
    private void OnDisable()
    {
        GameEvents.OnWaveComplete -= HandleWaveComplete;
    }
}

Additional Resources

Reference Files

For detailed guidance on specific topics:

  • references/lifecycle-detailed.md - Complete lifecycle method reference
  • references/serialization-guide.md - Advanced serialization patterns
  • references/component-patterns.md - Component architecture best practices
  • references/prefab-workflows.md - Comprehensive prefab usage guide

Quick Reference

Lifecycle Order: Awake → OnEnable → Start → FixedUpdate → Update → LateUpdate → OnDisable → OnDestroy

Serialization: [SerializeField] private over public

Components: Cache in Awake(), never call GetComponent in Update()

Prefabs: Use for reusable objects, test before applying changes


Follow these fundamentals to build solid Unity projects that are performant, maintainable, and bug-free.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

28.43%
按下载量换算266

Antigravity

25.54%
按下载量换算239

windsurf

17.25%
按下载量换算161

OpenCode

12.21%
按下载量换算114

Codex

7.77%
按下载量换算73

Gemini CLI

3.25%
按下载量换算30

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源字段存在多来源差异,先按来源优先级自动处理,无法消解时进入异常复核队列。

来源信息

继续浏览同类 Skills