unity

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Unity Engine

Unity引擎

Unity Fundamentals

Unity基础

Project Structure

项目结构

  • Assets Folder: Contains all project assets (models, textures, materials, scripts)
  • Scenes: Individual levels or environments
  • Prefabs: Reusable game object templates
  • Packages: External libraries and tools via Unity Package Manager
  • Project Settings: Global configuration for physics, graphics, input, etc.
  • Assets文件夹:包含所有项目资源(模型、纹理、材质、脚本)
  • Scenes(场景):独立关卡或环境
  • Prefabs(预制件):可复用的游戏对象模板
  • Packages(包):通过Unity Package Manager获取的外部库和工具
  • Project Settings(项目设置):物理、图形、输入等全局配置

GameObject Hierarchy

GameObject层级

  • Transform: Position, rotation, and scale of objects
  • Parent-Child Relationships: Object hierarchy for organization and transformation
  • Components: Modular functionality attached to GameObjects
  • Tags and Layers: Organization and filtering for game logic
  • Transform(变换组件):对象的位置、旋转和缩放
  • 父子关系:用于组织和变换的对象层级结构
  • Components(组件):附加到GameObject的模块化功能
  • Tags and Layers(标签与层):用于游戏逻辑的组织和过滤

Unity Scripting and C# Basics

Unity脚本与C#基础

MonoBehaviour Lifecycle

MonoBehaviour生命周期

  • Awake(): Called when script instance is loaded
  • Start(): Called before first Update frame
  • Update(): Called once per frame
  • FixedUpdate(): Called at fixed time intervals for physics
  • LateUpdate(): Called after all Update calls complete
  • OnDestroy(): Called when GameObject is destroyed
  • Awake():脚本实例加载时调用
  • Start():在第一帧Update之前调用
  • Update():每帧调用一次
  • FixedUpdate():按固定时间间隔调用,用于物理计算
  • LateUpdate():所有Update调用完成后调用
  • OnDestroy():GameObject销毁时调用

Common Unity APIs

常用Unity API

  • Transform: Access position, rotation, scale
  • Rigidbody: Physics simulation
  • Collider: Collision detection
  • Renderer: Visual rendering control
  • Animation: Animation playback control
  • Animator: State machine for animations
  • Transform:访问位置、旋转、缩放
  • Rigidbody(刚体):物理模拟
  • Collider(碰撞体):碰撞检测
  • Renderer(渲染器):视觉渲染控制
  • Animation(动画组件):动画播放控制
  • Animator(动画控制器):动画状态机

Prefab and Component Architecture

预制件与组件架构

Prefabs

预制件

  • Creating Prefabs: Drag GameObject to Project window
  • Prefab Variants: Inherit from base prefab with overrides
  • Nested Prefabs: Prefabs containing other prefabs
  • Prefab Mode: Edit prefabs in isolation
  • Prefab Overrides: Apply or revert changes to prefabs
  • 创建预制件:将GameObject拖拽到Project窗口
  • 预制件变体:继承自基础预制件并带有覆盖设置
  • 嵌套预制件:包含其他预制件的预制件
  • 预制件模式:独立编辑预制件
  • 预制件覆盖:应用或还原对预制件的修改

Components

组件

  • Mesh Renderer: Renders 3D meshes
  • Mesh Filter: Holds mesh data
  • Skinned Mesh Renderer: Renders animated meshes
  • Animator: Controls animation playback
  • Rigidbody: Physics simulation
  • Collider: Collision detection
  • Mesh Renderer(网格渲染器):渲染3D网格
  • Mesh Filter(网格过滤器):存储网格数据
  • Skinned Mesh Renderer(蒙皮网格渲染器):渲染带骨骼动画的网格
  • Animator(动画控制器):控制动画播放
  • Rigidbody(刚体):物理模拟
  • Collider(碰撞体):碰撞检测

Unity Asset Pipeline and Addressables

Unity资源管线与Addressables

Asset Import

资源导入

  • Model Import Settings: Scale, normals, tangents, animation clips
  • Texture Import Settings: Compression, max size, mipmaps
  • Audio Import Settings: Compression, load type, format
  • Asset Bundles: Package assets for runtime loading
  • 模型导入设置:缩放、法线、切线、动画片段
  • 纹理导入设置:压缩、最大尺寸、多级渐远纹理(mipmaps)
  • 音频导入设置:压缩、加载类型、格式
  • Asset Bundles(资源包):打包资源用于运行时加载

Addressables

Addressables

  • Addressable Assets: Load assets by address/label at runtime
  • Asset Groups: Organize assets by build settings
  • Content Catalog: Runtime database of addressable assets
  • Asset Loading: LoadAsync for asynchronous loading
  • Memory Management: Release and unload assets
  • Addressable Assets(可寻址资源):通过地址/标签在运行时加载资源
  • Asset Groups(资源组):按构建设置组织资源
  • Content Catalog(内容目录):可寻址资源的运行时数据库
  • 资源加载:使用LoadAsync进行异步加载
  • 内存管理:释放和卸载资源

Unity Optimization Techniques

Unity优化技巧

Rendering Optimization

渲染优化

  • Draw Call Batching: Combine similar objects into single draw call
  • GPU Instancing: Render multiple instances with single draw call
  • LOD Groups: Switch to lower detail models at distance
  • Occlusion Culling: Skip rendering objects not visible to camera
  • Lightmapping: Bake lighting for static objects
  • Draw Call批处理:将相似对象合并为单个Draw Call
  • GPU实例化:用单个Draw Call渲染多个实例
  • LOD Groups(细节层次组):在远距离切换为低细节模型
  • 遮挡剔除:跳过相机不可见对象的渲染
  • Lightmapping(光照烘焙):为静态对象烘焙光照

Performance Optimization

性能优化

  • Object Pooling: Reuse objects instead of instantiating/destroying
  • Script Optimization: Avoid Update when possible, use coroutines
  • Physics Optimization: Use fixed timestep, optimize colliders
  • Memory Optimization: Use object pooling, avoid allocations in Update
  • Profiling: Use Unity Profiler to identify bottlenecks
  • 对象池化:复用对象而非实例化/销毁
  • 脚本优化:尽量避免使用Update,改用协程
  • 物理优化:使用固定时间步长,优化碰撞体
  • 内存优化:使用对象池化,避免在Update中分配内存
  • 性能分析:使用Unity Profiler识别性能瓶颈

Unity Shader Graph and Visual Effects

Unity Shader Graph与视觉效果

Shader Graph

Shader Graph

  • Node-Based Shaders: Create shaders visually without code
  • PBR Master Node: Physically based rendering
  • Unlit Master Node: Non-physically based rendering
  • Custom Properties: Expose parameters to material inspector
  • Sub-graphs: Reusable shader logic
  • 基于节点的着色器:无需代码可视化创建着色器
  • PBR Master Node(PBR主节点):基于物理的渲染
  • Unlit Master Node(无光照主节点):非基于物理的渲染
  • 自定义属性:向材质检查器暴露参数
  • 子图:可复用的着色器逻辑

Visual Effects Graph

Visual Effects Graph

  • Particle Systems: Create complex particle effects
  • GPU Particles: High-performance particle simulation on GPU
  • Event Contexts: Trigger events based on particle behavior
  • Trails and Ribbons: Create trail effects
  • Collision Detection: Particle collision with scene objects
  • 粒子系统:创建复杂粒子效果
  • GPU粒子:在GPU上进行高性能粒子模拟
  • 事件上下文:根据粒子行为触发事件
  • 轨迹与带状效果:创建轨迹特效
  • 碰撞检测:粒子与场景对象的碰撞

Unity 3D Asset Integration

Unity 3D资源整合

Model Import

模型导入

  • FBX Import: Import 3D models from Blender, Maya, etc.
  • Scale Conversion: Handle different unit systems (cm vs m)
  • Animation Clips: Extract and configure animation clips
  • Rig Import: Import humanoid or generic rigs
  • Material Generation: Auto-generate materials from model
  • FBX导入:从Blender、Maya等工具导入3D模型
  • 缩放转换:处理不同单位系统(厘米vs米)
  • 动画片段:提取并配置动画片段
  • 骨骼导入:导入人形或通用骨骼
  • 材质生成:从模型自动生成材质

Material Setup

材质设置

  • Standard Shader: PBR-based standard shader
  • Shader Graph Materials: Custom shader graph materials
  • Material Properties: Albedo, metallic, smoothness, normal maps
  • Texture Slots: Assign textures to material properties
  • Material Variants: Create material variations for different states
  • Standard Shader(标准着色器):基于PBR的标准着色器
  • Shader Graph材质:自定义Shader Graph材质
  • 材质属性:Albedo(反照率)、金属度、光滑度、法线贴图
  • 纹理槽:为材质属性分配纹理
  • 材质变体:为不同状态创建材质变体