원클릭으로
unity
Unity Engine 游戏开发。适用于 Unity 项目、C# 脚本、场景设置、GameObject 系统、2D/3D 开发、物理、动画、UI、着色器 Shader、VR/AR 或任何 Unity 相关问题。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Unity Engine 游戏开发。适用于 Unity 项目、C# 脚本、场景设置、GameObject 系统、2D/3D 开发、物理、动画、UI、着色器 Shader、VR/AR 或任何 Unity 相关问题。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
DOTween Unity 动画插件。用于补间动画、UI 过渡、相机震动、序列、TextMeshPro 动画以及 Unity 中任何动画需求。此 Skill 应用于 Unity 项目中与 DOTween 动画系统相关的所有任务。
MediaPipe Unity Plugin 集成。用于计算机视觉任务、手部/面部/姿态追踪、手势识别、目标检测以及 Unity 中的 ML 解决方案。
PrimeTween Unity 高性能动画库。用于补间动画、UI 过渡、相机震动、序列以及 Unity 中任何零内存分配的动画需求。
创建有效 Skill 的指南。当用户想要创建新 Skill (或更新现有 Skill )以通过专业知识、工作流或工具集成扩展 Claude 能力时,应使用此 Skill 。
| name | unity |
| description | Unity Engine 游戏开发。适用于 Unity 项目、C# 脚本、场景设置、GameObject 系统、2D/3D 开发、物理、动画、UI、着色器 Shader、VR/AR 或任何 Unity 相关问题。 |
Unity 游戏开发的全面辅助,涵盖 C# 脚本、场景管理、物理、渲染、动画、UI 和平台特定功能。
此 Skill 应在以下情况下触发:
此 Skill 可与 Unity-MCP 结合实现实时 Unity Editor 控制!
Unity Skill(文档) + Unity-MCP(操作) = 完整的 AI 驱动开发
完整设置指南请参见 UNITY_MCP_INTEGRATION.md。
using UnityEngine;
public class GameController : MonoBehaviour
{
// 脚本实例加载时调用一次
void Awake()
{
// 在 Start() 之前初始化引用和设置
}
// 第一帧更新前调用一次
void Start()
{
// 依赖于其他对象的初始化逻辑
}
// 每帧调用
void Update()
{
// 输入处理和基于帧的逻辑
}
// 以固定时间间隔调用(物理)
void FixedUpdate()
{
// 物理相关代码(Rigidbody 力等)
}
// 所有 Update 函数完成后调用
void LateUpdate()
{
// 相机跟随、后处理逻辑
}
// 对象变为激活/启用时调用
void OnEnable() { }
// 对象变为禁用/不活动时调用
void OnDisable() { }
// MonoBehaviour 将被销毁时调用
void OnDestroy()
{
// 清理逻辑(取消订阅事件等)
}
}
using System.Collections;
using UnityEngine;
public class CoroutineExample : MonoBehaviour
{
void Start()
{
StartCoroutine(DelayedAction());
StartCoroutine(FadeOut(GetComponent<SpriteRenderer>(), 2.0f));
}
// 简单延迟
IEnumerator DelayedAction()
{
yield return new WaitForSeconds(2.0f);
Debug.Log("2秒后执行");
}
// 淡出效果
IEnumerator FadeOut(SpriteRenderer sprite, float duration)
{
float elapsed = 0f;
Color startColor = sprite.color;
while (elapsed < duration)
{
elapsed += Time.deltaTime;
float alpha = Mathf.Lerp(1f, 0f, elapsed / duration);
sprite.color = new Color(startColor.r, startColor.g, startColor.b, alpha);
yield return null; // 等待下一帧
}
}
}
using UnityEngine;
[CreateAssetMenu(fileName = "New Weapon", menuName = "Game/Weapon")]
public class WeaponData : ScriptableObject
{
public string weaponName;
public int damage;
public float fireRate;
public Sprite icon;
public GameObject projectilePrefab;
}
// 在 MonoBehaviour 中使用
public class WeaponSystem : MonoBehaviour
{
[SerializeField] private WeaponData currentWeapon;
public void Fire()
{
if (currentWeapon != null)
{
GameObject projectile = Instantiate(
currentWeapon.projectilePrefab,
transform.position,
transform.rotation
);
}
}
}
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class PlayerMovement : MonoBehaviour
{
[SerializeField] private float moveSpeed = 5f;
[SerializeField] private float jumpForce = 10f;
[SerializeField] private LayerMask groundLayer;
private Rigidbody rb;
private bool isGrounded;
void Awake()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
// 检查是否在地面上
isGrounded = Physics.Raycast(
transform.position,
Vector3.down,
1.1f,
groundLayer
);
// 移动
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(horizontal, 0f, vertical);
rb.AddForce(movement * moveSpeed);
}
void Update()
{
// 跳跃
if (Input.GetButtonDown("Jump") && isGrounded)
{
rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
}
}
}
using System.Collections.Generic;
using UnityEngine;
public class ObjectPool : MonoBehaviour
{
[SerializeField] private GameObject prefab;
[SerializeField] private int poolSize = 20;
private Queue<GameObject> pool = new Queue<GameObject>();
void Start()
{
for (int i = 0; i < poolSize; i++)
{
GameObject obj = Instantiate(prefab);
obj.SetActive(false);
pool.Enqueue(obj);
}
}
public GameObject GetObject()
{
if (pool.Count > 0)
{
GameObject obj = pool.Dequeue();
obj.SetActive(true);
return obj;
}
else
{
// 如需要则扩展池
GameObject obj = Instantiate(prefab);
return obj;
}
}
public void ReturnObject(GameObject obj)
{
obj.SetActive(false);
pool.Enqueue(obj);
}
}
using UnityEngine;
public class GameManager : MonoBehaviour
{
private static GameManager _instance;
public static GameManager Instance
{
get
{
if (_instance == null)
{
_instance = FindObjectOfType<GameManager>();
if (_instance == null)
{
GameObject go = new GameObject("GameManager");
_instance = go.AddComponent<GameManager>();
}
}
return _instance;
}
}
void Awake()
{
if (_instance != null && _instance != this)
{
Destroy(gameObject);
return;
}
_instance = this;
DontDestroyOnLoad(gameObject);
}
}
using System;
using UnityEngine;
public class EventManager : MonoBehaviour
{
public static event Action OnGameStart;
public static event Action<int> OnScoreChanged;
public static event Action OnGameOver;
public static void TriggerGameStart()
{
OnGameStart?.Invoke();
}
public static void TriggerScoreChanged(int newScore)
{
OnScoreChanged?.Invoke(newScore);
}
public static void TriggerGameOver()
{
OnGameOver?.Invoke();
}
}
// 使用:订阅和取消订阅
public class UIController : MonoBehaviour
{
void OnEnable()
{
EventManager.OnScoreChanged += UpdateScoreDisplay;
EventManager.OnGameOver += ShowGameOverScreen;
}
void OnDisable()
{
EventManager.OnScoreChanged -= UpdateScoreDisplay;
EventManager.OnGameOver -= ShowGameOverScreen;
}
void UpdateScoreDisplay(int score)
{
// 更新 UI
}
void ShowGameOverScreen()
{
// 显示游戏结束
}
}
using UnityEngine;
[RequireComponent(typeof(Rigidbody2D))]
public class CharacterController2D : MonoBehaviour
{
[SerializeField] private float moveSpeed = 5f;
[SerializeField] private float jumpForce = 10f;
[SerializeField] private Transform groundCheck;
[SerializeField] private LayerMask groundLayer;
private Rigidbody2D rb;
private bool isGrounded;
private bool facingRight = true;
void Awake()
{
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
// 地面检测
isGrounded = Physics2D.OverlapCircle(
groundCheck.position,
0.2f,
groundLayer
);
// 移动输入
float moveInput = Input.GetAxis("Horizontal");
rb.velocity = new Vector2(moveInput * moveSpeed, rb.velocity.y);
// 翻转角色
if (moveInput > 0 && !facingRight)
Flip();
else if (moveInput < 0 && facingRight)
Flip();
// 跳跃
if (Input.GetButtonDown("Jump") && isGrounded)
{
rb.velocity = new Vector2(rb.velocity.x, jumpForce);
}
}
void Flip()
{
facingRight = !facingRight;
Vector3 scale = transform.localScale;
scale.x *= -1;
transform.localScale = scale;
}
}
using UnityEngine;
using UnityEngine.UIElements;
public class UIController : MonoBehaviour
{
private UIDocument uiDocument;
private Label scoreLabel;
private Button startButton;
void OnEnable()
{
uiDocument = GetComponent<UIDocument>();
var root = uiDocument.rootVisualElement;
// 查询元素
scoreLabel = root.Q<Label>("score-label");
startButton = root.Q<Button>("start-button");
// 注册回调
startButton.clicked += OnStartButtonClicked;
}
void OnDisable()
{
startButton.clicked -= OnStartButtonClicked;
}
void OnStartButtonClicked()
{
Debug.Log("游戏开始!");
}
public void UpdateScore(int score)
{
scoreLabel.text = $"分数:{score}";
}
}
Shader "Custom/SimpleTextureShader"
{
Properties
{
_MainTex ("纹理", 2D) = "white" {}
_Color ("着色颜色", Color) = (1,1,1,1)
_Brightness ("亮度", Range(0, 2)) = 1
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
float4 _Color;
float _Brightness;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
col *= _Color * _Brightness;
return col;
}
ENDCG
}
}
}
此 Skill 包含按主题在 references/ 中组织的综合文档:
文档总计: 3,367 页,来自官方 Unity 手册和脚本 API
需要详细信息时使用 view 工具读取特定参考文件。
using UnityEngine; // Unity 核心类
using UnityEngine.UI; // UGUI 组件
using UnityEngine.UIElements; // UI Toolkit
using UnityEngine.SceneManagement; // 场景加载
using System.Collections; // 协程的 IEnumerator
using System.Collections.Generic; // Lists、Dictionaries
在此处添加用于常见自动化任务和实用程序的辅助脚本。
在此处添加模板、样板代码或示例 Unity 项目文件。
要使用最新的 Unity 文档刷新此 Skill :
skill-seekers scrape --config configs/unity.json此 Skill 来自官方 Unity 文档(手册 + 脚本 API),涵盖 3,367 页全面的 Unity Engine 信息。