0
0
Unityframework~10 mins

Tilemap painting 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 get the Tilemap component from the GameObject.

Unity
Tilemap tilemap = gameObject.GetComponent<[1]>();
Drag options to blanks, or click blank then click option'
ATransform
BRenderer
CTilemap
DCollider
Attempts:
3 left
💡 Hint
Common Mistakes
Using Renderer instead of Tilemap
Using Collider or Transform which are unrelated
2fill in blank
medium

Complete the code to set a tile at position (0, 0, 0) on the Tilemap.

Unity
tilemap.SetTile(new Vector3Int(0, 0, 0), [1]);
Drag options to blanks, or click blank then click option'
AgameObject
Bposition
Cnull
Dtile
Attempts:
3 left
💡 Hint
Common Mistakes
Passing null which removes a tile
Passing position or gameObject which are wrong types
3fill in blank
hard

Fix the error in the code to clear a tile at position (1, 2, 0).

Unity
tilemap.SetTile(new Vector3Int(1, 2, 0), [1]);
Drag options to blanks, or click blank then click option'
Anull
Btile
Cnew Tile()
DVector3Int.zero
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a tile instead of null
Passing a new Tile object which adds a tile
4fill in blank
hard

Fill both blanks to create a loop that paints tiles at positions (0,0) to (2,2).

Unity
for (int x = 0; x [1] 3; x++) {
    for (int y = 0; y [2] 3; y++) {
        tilemap.SetTile(new Vector3Int(x, y, 0), tile);
    }
}
Drag options to blanks, or click blank then click option'
A<
B<=
C>
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using <= which causes index 3 to be included
Using > or >= which never runs the loop
5fill in blank
hard

Fill all three blanks to create a dictionary of tile positions and paint only tiles with x greater than 1.

Unity
var tiles = new Dictionary<Vector3Int, TileBase>() {
    { new Vector3Int([1], 0, 0), tile1 },
    { new Vector3Int(1, [2], 0), tile2 },
    { new Vector3Int(2, 2, [3]), tile3 }
};
Drag options to blanks, or click blank then click option'
A2
B0
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong coordinates that don't match the condition
Setting z to non-zero which may cause confusion