Challenge - 5 Problems
Unity Editor 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 Editor script?
Consider this Unity Editor script that adds a menu item. What will be printed in the Console when you click the menu item Tools/Show Message?
Unity
using UnityEditor; using UnityEngine; public class EditorTest { [MenuItem("Tools/Show Message")] public static void ShowMessage() { Debug.Log("Hello from Unity Editor!"); } }
Attempts:
2 left
💡 Hint
Look at the Debug.Log statement inside the method called by the menu item.
✗ Incorrect
The method ShowMessage is linked to the menu item Tools/Show Message. When clicked, it runs and prints the message to the Console.
🧠 Conceptual
intermediate1:30remaining
Which Unity Editor window is used to inspect and modify GameObject properties?
In the Unity Editor interface, which window lets you see and change the properties of a selected GameObject?
Attempts:
2 left
💡 Hint
This window shows details about the selected object.
✗ Incorrect
The Inspector window displays all components and properties of the selected GameObject, allowing you to modify them.
🔧 Debug
advanced2:30remaining
Why does this custom Editor script cause an error?
This script tries to create a custom inspector for a component but causes an error. What is the cause?
Unity
using UnityEditor; using UnityEngine; [CustomEditor(typeof(MyComponent))] public class MyComponentEditor : Editor { public override void OnInspectorGUI() { DrawDefaultInspector(); if (GUILayout.Button("Press Me")) { Debug.Log("Button pressed"); } } } public class MyComponent : MonoBehaviour { public int value; }
Attempts:
2 left
💡 Hint
Custom Editor scripts must be placed in a special folder.
✗ Incorrect
Unity requires all Editor scripts to be inside a folder named 'Editor' to separate them from runtime scripts.
📝 Syntax
advanced2:00remaining
What error does this Unity Editor script produce?
What error will this script cause when compiled in Unity Editor?
Unity
using UnityEditor; using UnityEngine; public class EditorExample { [MenuItem("Tools/Do Something")] public static void DoSomething() { Debug.Log("Doing something"); } [MenuItem("Tools/Do Something", true)] public static bool ValidateDoSomething() { return false; } }
Attempts:
2 left
💡 Hint
Check the last line of the ValidateDoSomething method.
✗ Incorrect
The line 'return false' is missing a semicolon at the end, causing a syntax error.
🚀 Application
expert3:00remaining
How many items will appear in the Unity Editor's Project window after this script runs?
This Editor script creates assets in the Project window. How many assets will be visible after running the script?
Unity
using UnityEditor; using UnityEngine; public class AssetCreator { [MenuItem("Tools/Create Assets")] public static void CreateAssets() { for (int i = 0; i < 3; i++) { var asset = ScriptableObject.CreateInstance<ScriptableObject>(); AssetDatabase.CreateAsset(asset, $"Assets/Asset{i}.asset"); } AssetDatabase.SaveAssets(); } }
Attempts:
2 left
💡 Hint
Count how many times the loop runs and creates assets.
✗ Incorrect
The loop runs 3 times, creating 3 assets named Asset0.asset, Asset1.asset, and Asset2.asset.