0
0
Unityframework~10 mins

Why C# powers Unity behavior - Test Your Understanding

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

Complete the code to declare a public class in Unity using C#.

Unity
public class [1] : MonoBehaviour {}
Drag options to blanks, or click blank then click option'
APlayerController
Bvoid
CStart
DUpdate
Attempts:
3 left
💡 Hint
Common Mistakes
Using method names like 'Start' or 'Update' as class names.
2fill in blank
medium

Complete the code to define the Unity method that runs once when the script starts.

Unity
void [1]() {
    Debug.Log("Game started");
}
Drag options to blanks, or click blank then click option'
AStart
BFixedUpdate
CAwake
DUpdate
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing Start with Update or Awake.
3fill in blank
hard

Fix the error in the code to correctly update the position of a GameObject every frame.

Unity
void Update() {
    transform.position [1] new Vector3(0, 1, 0);
}
Drag options to blanks, or click blank then click option'
A=
B-=
C+=
D*=
Attempts:
3 left
💡 Hint
Common Mistakes
Using = replaces the position every frame, causing no movement.
4fill in blank
hard

Fill both blanks to create a dictionary that maps string keys to integer values in C#.

Unity
Dictionary<[1], [2]> scores = new Dictionary<[1], [2]>();
Drag options to blanks, or click blank then click option'
Astring
Bint
Cfloat
Dbool
Attempts:
3 left
💡 Hint
Common Mistakes
Using types like float or bool incorrectly for keys or values.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension-like initialization with conditions in C#.

Unity
var highScores = new Dictionary<[1], [2]> {
    {"Alice", 95},
    {"Bob", 85},
    {"Carol", 75}
}.Where(kv => kv.Value [3] 80).ToDictionary(kv => kv.Key, kv => kv.Value);
Drag options to blanks, or click blank then click option'
Astring
Bint
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong types or wrong comparison operators in the condition.