












































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Advanced Unity programming preparation covering C# scripting, game mechanics, debugging, optimization, Unity APIs, development workflows, and interactive application design concepts.
Typology: Exams
1 / 52
This page cannot be seen from the preview
Don't miss anything!













































Question 1. Which C# construct is most appropriate for implementing a finite-state machine where each state has its own update logic? A) Interface with a single Update method B) Abstract base class with virtual methods C) Enum with a switch statement in Update D) Delegates stored in a Dictionary Answer: B Explanation: An abstract base class lets each concrete state inherit and override its own Update logic, keeping state behavior encapsulated while sharing common functionality. Question 2. In Unity’s new Input System, which component defines the mapping between physical controls and logical actions? A) InputDevice B) InputActionAsset C) InputBinding D) InputManager Answer: B Explanation: An InputActionAsset contains action maps, actions, and bindings that translate device inputs into logical actions. Question 3. When you need to apply a constant force to a Rigidbody that should ignore its mass, which ForceMode is correct? A) Force B) Acceleration C) Impulse D) VelocityChange Answer: B Explanation: ForceMode.Acceleration adds force independent of mass, resulting in a constant acceleration.
Question 4. Which vector operation yields a value that is zero when two vectors are parallel? A) Dot product B) Cross product C) Magnitude D) Normalization Answer: B Explanation: The cross product of parallel vectors is the zero vector because the sine of the angle between them is zero. Question 5. To broadcast an event from a script without creating a hard reference to listeners, you should use: A) UnityEvent B) C# event with delegates C) SendMessage D) FindObjectOfType Answer: B Explanation: C# events with delegates provide compile-time safety and decoupling, allowing any subscriber to listen without the broadcaster knowing about them. Question 6. Which Unity class is used to serialize objects into JSON for local data persistence? A) JsonUtility B) BinaryFormatter C) PlayerPrefs D) ScriptableObject Answer: A
Answer: A Explanation: NetworkTransform replicates position, rotation, and scale of a GameObject on all clients. Question 10. When customizing NavMeshAgent movement, which property restricts the agent’s speed on steep slopes? A) radius B) height C) slopeLimit D) stepOffset Answer: C Explanation: slopeLimit defines the maximum walkable angle; agents will stop or slide on steeper surfaces. Question 11. A Prefab Variant differs from a regular Prefab because it: A) Stores only a reference to the original prefab B) Allows overriding specific properties while inheriting the rest C) Cannot be instantiated at runtime D) Is always loaded from the Resources folder Answer: B Explanation: Variants inherit the base prefab’s structure and can override selected components, fields, or child objects. Question 12. To change a material’s color per renderer without creating a new material instance, you should use: A) renderer.sharedMaterial.color B) MaterialPropertyBlock C) renderer.material = new Material(original) D) Shader.SetGlobalColor
Answer: B Explanation: MaterialPropertyBlock lets you modify material properties for a specific renderer without allocating a new material, preventing memory leaks. Question 13. Which component of the Animation Rigging package provides two-bone inverse kinematics for a character’s arm? A) ChainIKConstraint B) TwoBoneIKConstraint C) MultiAimConstraint D) RigBuilder Answer: B Explanation: TwoBoneIKConstraint solves IK for a simple two-bone chain, such as an arm with shoulder and elbow. Question 14. In the Visual Effect Graph, which node type is used to spawn particles based on a custom script? A) Initialize Particle B) Set Attribute C) Scriptable Spawn D) Output Particle Quad Answer: C Explanation: The Scriptable Spawn node lets a C# script trigger particle emission with custom parameters. Question 15. Which Unity API method loads a scene additively while allowing you to track progress? A) SceneManager.LoadSceneAsync(name, LoadSceneMode.Additive) B) SceneManager.LoadScene(name) C) Resources.LoadAsync(name) D) Addressables.LoadSceneAsync(name)
D) Physics Debugger Answer: B Explanation: The Frame Debugger visualizes each draw call and its GPU cost for the current frame. Question 19. To reduce garbage collection spikes caused by frequent string concatenation, you should: A) Use the + operator in Update B) Use StringBuilder or cached string formats C) Call Resources.UnloadUnusedAssets each frame D) Disable GC Answer: B Explanation: StringBuilder reuses a buffer, minimizing allocations compared to repeated string concatenation. Question 20. In the Universal Render Pipeline, which asset controls the overall rendering configuration such as HDR and MSAA? A) URP Asset (UniversalRenderPipelineAsset) B) GraphicsSettings C) LightmapSettings D) ShaderGraph Answer: A Explanation: The URP Asset stores pipeline-wide settings like HDR, MSAA, and render scale. Question 21. Which C# design principle encourages a class to have only one reason to change? A) Open/Closed Principle B) Liskov Substitution Principle
C) Single Responsibility Principle D) Interface Segregation Principle Answer: C Explanation: The Single Responsibility Principle states that a class should have one responsibility, i.e., one reason to change. Question 22. When debugging a NullReferenceException in Unity, the most efficient first step is to: A) Search the entire project for the variable name B) Enable “Script Debugging” in the Build Settings C) Inspect the call stack in the IDE to locate the offending line D) Re-import all assets Answer: C Explanation: The call stack pinpoints the exact line where the null reference occurred, allowing targeted inspection. Question 23. Which Git command is used to resolve a merge conflict after editing the conflicted files? A) git commit B) git rebase C) git merge --continue D) git add Answer: D Explanation: After fixing conflicts, you stage the resolved files with git add, then complete the merge with git commit. Question 24. In Unity Test Framework, which attribute marks a method as a performance test? A) [Test]
A) actionMap.Enable() B) actionMap.Activate() C) InputSystem.Enable(actionMap) D) actionMap.SetActive(true) Answer: A Explanation: Calling Enable() on an InputActionMap activates all its actions. Question 28. Which Unity API converts a world-space direction into a local-space direction for a given Transform? A) Transform.InverseTransformDirection B) Transform.TransformDirection C) Transform.InverseTransformPoint D) Transform.TransformPoint Answer: A Explanation: InverseTransformDirection maps a world direction into the Transform’s local coordinate space. Question 29. To ensure a UI layout scales correctly on different screen sizes using UGUI, you should add which component to the Canvas? A) CanvasScaler B) LayoutGroup C) RectMask2D D) ContentSizeFitter Answer: A Explanation: CanvasScaler adjusts UI element sizes based on screen resolution and reference resolution. Question 30. Which property of a NavMeshAgent controls how quickly it rotates to face its movement direction?
A) angularSpeed B) speed C) acceleration D) radius Answer: A Explanation: angularSpeed defines the maximum turning speed of the agent. Question 31. When creating a Prefab Variant, which of the following is NOT inherited from its base prefab? A) Child hierarchy B) Component scripts attached to the root C) Modified property values in the variant D) Serialized field defaults Answer: C Explanation: Property overrides in the variant are unique to it and do not affect the base prefab. Question 32. Which method should you call to manually release a pooled object back to its pool? A) Destroy(obj) B) obj.SetActive(false) C) pool.Release(obj) D) Resources.UnloadAsset(obj) Answer: C Explanation: Object pools expose a Release method to return the object for future reuse without destroying it. Question 33. In URP, which renderer feature allows you to render objects with a different material after the main pass?
A) InvokeRepeating B) WaitForSeconds C) WaitForEndOfFrame D) CustomYieldInstruction Answer: A Explanation: InvokeRepeating can schedule a method call after a delay measured in seconds; for frame-based delays, you can use Invoke with a delay of 0 and count frames manually, but the most direct frame-based alternative is using a coroutine. However, Invoke is the built-in non-coroutine method for timed calls. Question 37. In the context of Unity’s Addressables, what does the term “catalog” refer to? A) A list of all scenes in the build B) The runtime database mapping keys to asset locations C) The editor window for managing assets D) A JSON file containing player preferences Answer: B Explanation: The Addressables catalog stores mappings from addressable keys to their actual asset bundles or locations. Question 38. Which Unity lifecycle method is called only once when a script instance is first enabled? A) Awake B) Start C) OnEnable D) Update Answer: B Explanation: Start runs after Awake and only the first time the component becomes enabled.
Question 39. When using the Physics.SphereCast, what does the “radius” parameter define? A) The size of the sphere used for the cast B) The distance the ray travels C) The thickness of the collider hit D) The mass of the sphere Answer: A Explanation: Radius determines the sphere’s size that sweeps along the cast direction. Question 40. Which attribute can be placed on a field to make it editable in the Unity Inspector while keeping it private? A) [HideInInspector] B) [SerializeField] C) [ReadOnly] D) [NonSerialized] Answer: B Explanation: [SerializeField] forces Unity to serialize a private field, exposing it in the Inspector. Question 41. In a multi-scene setup, which method ensures that a GameObject persists across scene loads? A) DontDestroyOnLoad(gameObject) B) SceneManager.MoveGameObjectToScene C) GameObject.SetActive(true) D) Object.DontUnload Answer: A
Answer: B Explanation: OverlapSphereNonAlloc fills a pre-allocated array, avoiding garbage allocation. Question 45. In the context of C# events, what does the “?.Invoke” syntax protect against? A) NullReferenceException when there are no subscribers B) Thread-safety issues C) Memory leaks D) Overloading the event Answer: A Explanation: The null-conditional operator checks if the delegate is non-null before invoking it. Question 46. Which Unity feature allows you to bake lighting information into textures for static objects? A) Real-time Global Illumination B) Light Probes C) Lightmap baking D) Reflection Probes Answer: C Explanation: Lightmap baking stores pre-computed lighting on textures, improving performance for static geometry. Question 47. To ensure a UI element maintains a square aspect ratio regardless of screen size, you should use which component? A) AspectRatioFitter B) LayoutElement C) ContentSizeFitter D) CanvasScaler
Answer: A Explanation: AspectRatioFitter enforces a specified width-to-height ratio on the RectTransform. Question 48. Which method is called on a NetworkBehaviour when a client receives a ServerRpc? A) OnServerRpcReceived B) ServerRpc C) ClientRpc D) OnRpcMessage Answer: C Explanation: ClientRpc methods are invoked on clients by the server; ServerRpc runs on the server when called by a client. Question 49. In Unity’s Visual Effect Graph, which type of context is responsible for spawning particles over time? A) Initialize B) Update C) Output D) Spawn Answer: D Explanation: The Spawn context defines when and how many particles are emitted. Question 50. Which of the following is NOT a valid Unity coroutine yield instruction? A) WaitForSeconds B) WaitForFixedUpdate C) WaitUntil
C) [ExecuteInEditMode] D) [HideInInspector] Answer: A Explanation: [Preserve] tells the Unity linker to keep the referenced shader or method. Question 54. Which design pattern is exemplified by a system where objects subscribe to a central event dispatcher and are notified without the dispatcher knowing the concrete subscriber types? A) Factory B) Observer C) Singleton D) Strategy Answer: B Explanation: The Observer pattern decouples subjects and observers through a subscription mechanism. Question 55. In Unity’s new Input System, which method is used to read the current value of a Vector2 action? A) ReadValue() B) GetValue() C) GetCurrent() D) Value() Answer: A Explanation: ReadValue() returns the current control value for the specified type. Question 56. Which Unity class provides a way to create a custom editor window? A) EditorWindow
B) ScriptableObject C) MonoBehaviour D) CustomEditor Answer: A Explanation: Inherit from EditorWindow to define and display custom tools in the Unity editor. Question 57. When performing a raycast against UI elements, which component must be present on the Canvas? A) GraphicRaycaster B) CanvasScaler C) CanvasGroup D) EventSystem Answer: A Explanation: GraphicRaycaster processes raycasts against UI graphics. Question 58. Which attribute on a field ensures that it is not serialized by Unity, even if it is public? A) [HideInInspector] B) [NonSerialized] C) [SerializeField] D) [ReadOnly] Answer: B Explanation: [NonSerialized] tells Unity to ignore the field during serialization. Question 59. To trigger an animation transition via code, you should call which Animator method? A) Play(stateName)