0
0
Unityframework~10 mins

Unity Editor interface - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to open the Unity Editor's Console window.

Unity
EditorWindow.GetWindow(typeof([1]));
Drag options to blanks, or click blank then click option'
AConsoleWindow
BSceneView
CGameView
DInspectorWindow
Attempts:
3 left
💡 Hint
Common Mistakes
Using GameView or SceneView instead of ConsoleWindow.
Forgetting to use typeof() around the window type.
2fill in blank
medium

Complete the code to add a menu item in Unity Editor under 'Tools' menu.

Unity
[MenuItem("Tools/[1]")]
static void MyTool() {
    Debug.Log("Tool activated");
}
Drag options to blanks, or click blank then click option'
AShowInspector
BOpenConsole
CStartGame
DMyTool
Attempts:
3 left
💡 Hint
Common Mistakes
Using names that don't match the method or are invalid menu paths.
Missing the MenuItem attribute.
3fill in blank
hard

Fix the error in the code to correctly create a custom Editor window named 'MyWindow'.

Unity
public class MyWindow : EditorWindow {
    [MenuItem("Window/My Window")]
    public static void ShowWindow() {
        var window = GetWindow<[1]>();
        window.titleContent = new GUIContent("My Window");
        window.Show();
    }
}
Drag options to blanks, or click blank then click option'
AEditorWindow
BMyWindow
CWindow
DMyEditor
Attempts:
3 left
💡 Hint
Common Mistakes
Using EditorWindow instead of the custom class name.
Using a wrong or undefined class name.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps GameObject names to their active state in the scene.

Unity
var activeStates = new Dictionary<string, bool>() {
    { [1], [2] }
};
Drag options to blanks, or click blank then click option'
AgameObject.name
BgameObject.activeSelf
CgameObject.tag
DgameObject.transform
Attempts:
3 left
💡 Hint
Common Mistakes
Using transform or tag instead of name for the key.
Using incorrect property for active state.
5fill in blank
hard

Fill all three blanks to create a LINQ query that selects names of active GameObjects from a list.

Unity
var activeNames = from [1] in gameObjects
                  where [2].activeSelf == [3]
                  select [1].name;
Drag options to blanks, or click blank then click option'
Aobj
Ctrue
DgameObject
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent variable names in the query.
Using false instead of true for filtering active objects.