Challenge - 5 Problems
Scene Hierarchy Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Unity C# script affecting the hierarchy?
Consider the following Unity C# script attached to a GameObject in a scene. What will be printed in the Console when the scene starts?
Unity
using UnityEngine; public class HierarchyTest : MonoBehaviour { void Start() { Debug.Log(transform.childCount); foreach (Transform child in transform) { Debug.Log(child.name); } } }
Attempts:
2 left
💡 Hint
Think about what transform.childCount returns and how foreach over transform works.
✗ Incorrect
transform.childCount returns how many children the GameObject has. The foreach loop iterates over each child Transform, printing their names.
🧠 Conceptual
intermediate1:30remaining
Which statement about the Scene Hierarchy window is true?
Select the correct statement about the Unity Scene Hierarchy window.
Attempts:
2 left
💡 Hint
Think about whether inactive GameObjects appear in the hierarchy.
✗ Incorrect
The Scene Hierarchy window shows all GameObjects in the current scene, including those that are inactive. Inactive GameObjects appear grayed out.
🔧 Debug
advanced2:30remaining
Why does this code not find a child GameObject in the hierarchy?
This code tries to find a child GameObject named "Enemy" but always returns null. Why?
GameObject enemy = transform.Find("Enemy").gameObject;
Attempts:
2 left
💡 Hint
Remember how transform.Find works with paths and direct children.
✗ Incorrect
transform.Find only finds direct children or children by path. If "Enemy" is nested deeper without a path, it returns null.
📝 Syntax
advanced2:00remaining
Which code snippet correctly moves a GameObject under a new parent in the hierarchy?
Select the correct code to set the parent of a GameObject named "child" to another GameObject named "parent".
Attempts:
2 left
💡 Hint
Check the correct method and parameter type for setting a parent transform.
✗ Incorrect
SetParent expects a Transform parameter. parent is a GameObject, so use parent.transform.
🚀 Application
expert3:00remaining
How many GameObjects will be active in the scene after this code runs?
Given a GameObject "Root" with 3 children: "A" (active), "B" (inactive), and "C" (active). The code below runs:
foreach (Transform child in root.transform) {
child.gameObject.SetActive(false);
}
root.SetActive(true);
Attempts:
2 left
💡 Hint
Remember what SetActive does to children and the parent separately.
✗ Incorrect
The code disables all children, so none are active. The root remains active, so only 1 GameObject is active.