0
0
Unityframework~10 mins

Audio Listener 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 add an Audio Listener component to the GameObject.

Unity
gameObject.AddComponent<[1]>();
Drag options to blanks, or click blank then click option'
AAudioSource
BAudioListener
CAudioClip
DAudioMixer
Attempts:
3 left
💡 Hint
Common Mistakes
Using AudioSource instead of AudioListener.
Confusing AudioClip with AudioListener.
2fill in blank
medium

Complete the code to check if the GameObject has an Audio Listener component.

Unity
if (gameObject.GetComponent<[1]>() != null) {
    Debug.Log("Audio Listener found.");
}
Drag options to blanks, or click blank then click option'
AAudioClip
BAudioSource
CAudioListener
DAudioMixer
Attempts:
3 left
💡 Hint
Common Mistakes
Checking for AudioSource instead of AudioListener.
Using wrong component type in GetComponent.
3fill in blank
hard

Fix the error in the code to properly mute the Audio Listener.

Unity
AudioListener.[1] = true;
Drag options to blanks, or click blank then click option'
Apause
Benabled
Cmute
Dstop
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'mute' property which does not exist.
Trying to call a method instead of setting a property.
4fill in blank
hard

Fill both blanks to create a new GameObject and add an Audio Listener component to it.

Unity
GameObject [1] = new GameObject();
[2].AddComponent<AudioListener>();
Drag options to blanks, or click blank then click option'
AaudioListenerObject
BaudioSourceObject
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names in the two blanks.
Using 'audioSourceObject' which is misleading.
5fill in blank
hard

Fill all three blanks to disable the Audio Listener component on a GameObject named 'player'.

Unity
AudioListener [1] = player.GetComponent<[2]>();
if ([3] != null) {
    [3].enabled = false;
}
Drag options to blanks, or click blank then click option'
Alistener
BAudioListener
DaudioListener
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently.
Using wrong component type in GetComponent.