brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
unityExpert game development with Unity - engine architecture, C# scripting, DOTS ECS, rendering (URP/HDRP), physics, animation, UI, asset pipeline, multiplayer, and performance.
Independent GitHub snapshot · Automated classification · Original documentation governs
Unity is a component-based game engine built around GameObjects, MonoBehaviours, and a C# scripting layer. Modern Unity adds Data-Oriented Technology Stack (DOTS/E.C.S.) and two Scriptable Render Pipelines (URP/HDRP). This guide covers how a lead engineer thinks about Unity: architecture, C# performance, data-oriented design, rendering, physics, multiplayer, and profiling.
Unity Player/Editor
Application (UnityEngine)
SceneManager -> load/unload Scenes (additive)
GameObject (identity + transform)
Component (MonoBehaviour, Renderer, Collider, Animator...)
PlayerLoop: (fixed update order, engine-driven)
ScriptableRunLoops -> custom systems injected
Module systems: Physics (PhysX/Box2D), Audio (FMOD), UI (UGUI/UI Toolkit),
Rendering (URP/HDRP/Built-in), Input (new Input System)
Within one frame Unity calls systems in a fixed order:
void Update() // per rendered frame
void FixedUpdate() // fixed timestep: physics, network ticks (default 0.02s)
void LateUpdate() // camera follow, post-movement
Rules:
FixedUpdate or use rb.velocity only in FixedUpdate. Changing transform in Update fights the physics solver.Addressables/SceneManager.LoadSceneAsync.LoadSceneAsync + AllowSceneActivation = false to keep the load from blocking.SceneManager.MergeScenes or DontDestroyOnLoad root object.public class Health : MonoBehaviour {
public int maxHp = 100;
int current;
void OnEnable() { /* add self to manager lists */ }
void OnDisable() { /* remove self */ }
}
GetComponent<T>() per frame per object is a hot-path mistake:
Awake() once.TryGetComponent.GetComponentsInChildren only at load or on structural change.Find.These are O(n) with allocations. They MUST not run on the per-frame path. For singletons, register in Awake, destroy in OnDestroy:
public static GameManager I; // global accessor
void Awake() { I = this; }
void OnDestroy() { if (I == this) I = null; }
Unity DOTS replaces MonoBehaviours with archetype-based ECS:
// Component - plain struct, no MonoBehaviour
public struct Velocity : IComponentData { public float3 Value; }
// System
[BurstCompile]
partial struct MoveSystem : ISystem {
[BurstCompile]
public void OnUpdate(ref SystemState state) {
foreach (var (transform, v) in
SystemAPI.Query<RefRW<LocalTransform>, RefRO<Velocity>>())
{
transform.ValueRW.Position += v.ValueRO.Value * SystemAPI.Time.DeltaTime;
}
}
}
Burst + Jobs compiles to native SIMD-optimized code.| Need | Path |
|---|---|
| 1000s of agents, bullets, particles | DOTS/ECS + Burst + Jobs |
| Rapid prototyping / small games | Classic GameObject/MonoBehaviours |
| UI, gameplay narrative, inventory | Classic (UGUI) |
| Massive open world streaming | DOTS SubScene streaming |
| Pipeline | Use |
|---|---|
| Built-in | Legacy, quick prototypes, simple mobile games |
| URP | Default for most new projects (PC+mobile), SRP Batcher optimal |
| HDRP | Film-grade lighting: deferred, ray tracing, volumetrics, high-end PC/console |
ScriptableRenderer (custom) | You own pass ordering; use with RenderGraph |
ScriptableRenderPipeline; they run in the Rendering.Update player-loop phase.UseSRPBatcher) — batches dynamic shadows+lit objects with compatible materials.Graphics.DrawMeshInstanced for repeated meshes (grass, crowds, particles).KeywordEnum, MaterialPropertyBlock for per-object color).HLSLPROGRAM blocks and #pragma target 3.0+.#pragma multi_compile _ _ALPHATEST_ON; use #pragma shader_feature_local to avoid variants.Physics.Burst/Physics.Solver or a dedicated CCD sensor.isTrigger = true) to avoid touches every frame.Physics.IgnoreLayerCollision(playerLayer, enemyLayer, true) reduces contact generation.Physics.SyncTransforms() forces syncing; avoid calling per-frame.Time.deltaTime may be 0 on pause; use Time.unscaledDeltaTime for UI.OnAnimationEvent or AnimationEvent binding.AnimationUpdateMode fixed with simple lerps.Vertex Buffer reuse, disable raycast on static.RectTransforms, minify GraphicRaycaster blockers.Addressables = load by key, async, memory-managed:
Addressables.LoadAssetAsync<GameObject>("enemies/wolf").Completed += h => {
var go = Instantiate(h.Result);
go.AddComponent<DeferredUnload>();
};
Addressables.Release(handle);
AssetReference fields instead of hardcoded strings.addressables remote catalog for updates.Instantiate(referencedObject) body must be released too.Texture2D.streamingEnabled) or Addressables load in OnTriggerEnter.AudioClip.Create streaming for ambience.Resources.Load in Update; use Resources.LoadAll once.[ServerRpc] from client to server; [ClientRpc] from server to clients.NetworkVariable<T> — beware of per-frame NetworkVariable writes (delta encode, avoid 60/s floats).PredictedPlayer pattern with client-side NetworkTransform interpolation.ExecuteInEditMode scripts only where needed; keep editor-only work in #if UNITY_EDITOR.transform.position in a loop (accessing Transform is cheap-ish, but allocations from Find/GetComponentsInChildren are not).NativeArray/NativeList in jobs.FixedUpdate only for physics; game logic in Update.Animator cost.Camera.main cached; avoid in Update.| System | Budget (ms) @ 60fps |
|---|---|
| Simulation (Update) | 2.0 |
| Physics (Fixed) | 2.0 |
| Animation | 2.0 |
| AI / NavMesh | 1.5 |
| Rendering (CPU submit) | 3.0 |
| Rendering (GPU) | 8.3–14.0 |
| UI | 1.0 |
| Netcode | 1.0 |
| Misc / Driver | 2.0 |
Total must fit in 16.6ms (or 1000/refresh).
Assets/
Scripts/ # namespaces by system
Scenes/
Prefabs/
Addressables/ # addressable groups
Materials/
Textures/
Audio/
_BuildTools/ # editor scripts, CI
.gitignore: Library/ Temp/ Logs/ UserSettings/
Use .asmdef (assembly definition) per folder to speed up compile times and control references.
| Anti-pattern | Consequence | Fix |
|---|---|---|
FindObjectOfType in Update | GC spikes, slow | cache in Awake |
| Rigidbody move in Update | physics jitter | FixedUpdate + rb.Move |
| Per-frame allocations (strings) | GC pauses | string builders, pooling |
| Resources.Load in loop | load spikes | Addressables + cache |
| One Canvas for everything | layout rebuild | split by update frequency |
| Scripts in Editor without serialization | lost state | [SerializedField] |
| Not using .asmdef | long compile | per-system asmdefs |
| Physics without layer matrix | wasted contacts | IgnoreLayerCollision |
skills/game/game-development/vulkan/SKILL.md).skills/game/game-engine/ecs-pattern/SKILL.md.skills/game/game-development/unity-csharp/SKILL.md — Unity C# scripting and DOTS internalsskills/game/game-engine/ecs-pattern/references/unity-dots-in-practice.md — DOTS in real projectsskills/game/game-engine/patterns/references/game-loop-and-timestep.md — update timing patternsskills/game/multiplayer-netcode/SKILL.md — netcode patterns & predictionskills/game/game-development/physics-engine/SKILL.md — physics internals used by engines