< Summary

Class:PlayQuickSound
Assembly:Test
File(s):D:/--UnityProject/VR/_____ISSTA 26/VR-Room/Assets/_Course Library/Scripts/Test/PlayQuickSound.cs
Covered lines:19
Uncovered lines:0
Coverable lines:19
Total lines:42
Line coverage:100% (19 of 19)
Covered branches:0
Total branches:0
Covered methods:4
Total methods:4
Method coverage:100% (4 of 4)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
PlayQuickSound()0%000100%
Awake()0%000100%
Play()0%000100%
OnValidate()0%000100%

File(s)

D:/--UnityProject/VR/_____ISSTA 26/VR-Room/Assets/_Course Library/Scripts/Test/PlayQuickSound.cs

#LineLine coverage
 1using UnityEngine;
 2
 3/// <summary>
 4/// Play a simple sounds using Play one shot with volume, and pitch
 5/// </summary>
 6[RequireComponent(typeof(AudioSource))]
 7public class PlayQuickSound : MonoBehaviour
 8{
 9    [Tooltip("The sound that is played")]
 1310    public AudioClip sound = null;
 11
 12    [Tooltip("The volume of the sound")]
 1313    public float volume = 1.0f;
 14
 15    [Tooltip("The range of pitch the sound is played at (-pitch, pitch)")]
 1316    [Range(0, 1)] public float randomPitchVariance = 0.0f;
 17
 1318    private AudioSource audioSource = null;
 19
 1320    private float defaultPitch = 1.0f;
 21
 22    private void Awake()
 323    {
 324        audioSource = GetComponent<AudioSource>();
 325    }
 26
 27    public void Play()
 528    {
 529        float randomVariance = Random.Range(-randomPitchVariance, randomPitchVariance);
 530        randomVariance += defaultPitch;
 31
 532        audioSource.pitch = randomVariance;
 533        audioSource.PlayOneShot(sound, volume);
 534        audioSource.pitch = defaultPitch;
 535    }
 36
 37    private void OnValidate()
 1338    {
 1339        AudioSource audioSource = GetComponent<AudioSource>();
 1340        audioSource.playOnAwake = false;
 1341    }
 42}