Unity Advanced Topics 2 — Questions and Answers
Question 1: Which Unity feature compiles C# scripts to native code for improved runtime performance?
- IL2CPP (Correct answer)
- Mono JIT
- Roslyn
- MonoBehaviour
Correct answer: IL2CPP
IL2CPP converts IL bytecode to C++ then compiles it to native machine code.
Question 2: What is the primary purpose of the Unity Job System?
- Schedule multithreaded code safely (Correct answer)
- Manage build pipelines
- Handle asset imports
- Render UI elements
Correct answer: Schedule multithreaded code safely
The Job System lets you write safe, fast multithreaded code that runs across CPU cores.
Question 3: In the Burst compiler, which code is optimized?
- Jobs and function-pointers using HPC# (Correct answer)
- All MonoBehaviour Update calls
- Shader code only
- UI Toolkit layouts
Correct answer: Jobs and function-pointers using HPC#
Burst compiles a subset of C# (HPC#) used in jobs into highly optimized native code.
Question 4: What does the Entity Component System (ECS) primarily improve?
- Data-oriented cache-friendly performance (Correct answer)
- Visual scripting workflows
- Audio mixing
- Texture compression
Correct answer: Data-oriented cache-friendly performance
ECS organizes data for better memory layout and cache utilization at scale.
Question 5: Which attribute marks a struct as a job that runs in parallel over an array?
- IJobParallelFor (Correct answer)
- IEnumerator
- Coroutine
- AsyncTask
Correct answer: IJobParallelFor
IJobParallelFor splits work across indices to run iterations on multiple threads.
Question 6: Why must NativeContainers be disposed in the Job System?
- They use unmanaged memory not freed by GC (Correct answer)
- They are stored on disk
- They lock the GPU
- They require network access
Correct answer: They use unmanaged memory not freed by GC
NativeContainers allocate unmanaged memory that must be manually disposed to avoid leaks.
Question 7: What is the role of a JobHandle in Unity's Job System?
- Track dependencies and completion of jobs (Correct answer)
- Store mesh data
- Reference a prefab
- Hold shader uniforms
Correct answer: Track dependencies and completion of jobs
A JobHandle is used to schedule dependencies and ensure a job completes before reading results.
Which Unity feature compiles C# scripts to native code for improved runtime performance?