< Summary

Class:PlayQuickSound
Assembly:Test
File(s):E:/Unity/Unity Project/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)

E:/Unity/Unity Project/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")]
 610    public AudioClip sound = null;
 11
 12    [Tooltip("The volume of the sound")]
 613    public float volume = 1.0f;
 14
 15    [Tooltip("The range of pitch the sound is played at (-pitch, pitch)")]
 616    [Range(0, 1)] public float randomPitchVariance = 0.0f;
 17
 618    private AudioSource audioSource = null;
 19
 620    private float defaultPitch = 1.0f;
 21
 22    private void Awake()
 323    {
 324        audioSource = GetComponent<AudioSource>();
 325    }
 26
 27    public void Play()
 628    {
 629        float randomVariance = Random.Range(-randomPitchVariance, randomPitchVariance);
 630        randomVariance += defaultPitch;
 31
 632        audioSource.pitch = randomVariance;
 633        audioSource.PlayOneShot(sound, volume);
 634        audioSource.pitch = defaultPitch;
 635    }
 36
 37    private void OnValidate()
 638    {
 639        AudioSource audioSource = GetComponent<AudioSource>();
 640        audioSource.playOnAwake = false;
 641    }
 42}