0
0
Unityframework~10 mins

Project structure and folders in Unity - Interactive Code Practice

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

Complete the code to create a new folder named 'Scripts' inside the Assets folder.

Unity
using UnityEditor;

public class CreateFolder {
    [MenuItem("Assets/Create/Scripts Folder")]
    public static void CreateScriptsFolder() {
        AssetDatabase.CreateFolder("Assets", "[1]");
    }
}
Drag options to blanks, or click blank then click option'
AScripts
BTextures
CPrefabs
DMaterials
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong folder name like 'Texture' or 'Prefabs'.
Forgetting to specify the parent folder 'Assets'.
2fill in blank
medium

Complete the code to load a prefab named 'Enemy' from the 'Prefabs' folder inside Assets.

Unity
using UnityEngine;

public class LoadPrefab : MonoBehaviour {
    public GameObject enemyPrefab;

    void Start() {
        enemyPrefab = Resources.Load<GameObject>("[1]/Enemy");
    }
}
Drag options to blanks, or click blank then click option'
AScripts
BMaterials
CPrefabs
DTextures
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Scripts' or 'Materials' instead of 'Prefabs'.
Forgetting to include the folder name in the path.
3fill in blank
hard

Fix the error in the code to correctly save a new material asset inside the 'Materials' folder.

Unity
using UnityEditor;
using UnityEngine;

public class SaveMaterial {
    public static void CreateMaterial() {
        Material mat = new Material(Shader.Find("Standard"));
        AssetDatabase.CreateAsset(mat, "Assets/[1]/NewMaterial.mat");
        AssetDatabase.SaveAssets();
    }
}
Drag options to blanks, or click blank then click option'
AScripts
BMaterials
CPrefabs
DTextures
Attempts:
3 left
💡 Hint
Common Mistakes
Saving the material in the wrong folder like 'Scripts' or 'Textures'.
Not including the folder name in the asset path.
4fill in blank
hard

Fill both blanks to create a dictionary that maps folder names to their typical content type.

Unity
var folderContent = new Dictionary<string, string> {
    {"Scripts", "[1]"},
    {"Prefabs", "[2]"}
};
Drag options to blanks, or click blank then click option'
ACode files
BTextures
CGame objects
DAudio files
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up folder content types.
Using unrelated content types like 'Audio files' for Scripts.
5fill in blank
hard

Fill all three blanks to create a method that checks if a folder exists and creates it if missing.

Unity
using UnityEditor;

public class FolderHelper {
    public static void EnsureFolder(string folderName) {
        if (!AssetDatabase.IsValidFolder($"Assets/[1]")) {
            AssetDatabase.CreateFolder("Assets", [2] + [3]);
        }
    }
}
Drag options to blanks, or click blank then click option'
AfolderName
C""
D"/"
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names or adding extra slashes.
Confusing the order of parameters in CreateFolder.