< Summary

Class:AudioManager
Assembly:Test
File(s):D:/--UnityProject/VR/VRExplorer_subjects/VGuns-Unity-VR/Assets/Test/AudioManager.cs
Covered lines:21
Uncovered lines:6
Coverable lines:27
Total lines:51
Line coverage:77.7% (21 of 27)
Covered branches:0
Total branches:0
Covered methods:2
Total methods:2
Method coverage:100% (2 of 2)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%00085%
Play(...)0%00070%

File(s)

D:/--UnityProject/VR/VRExplorer_subjects/VGuns-Unity-VR/Assets/Test/AudioManager.cs

#LineLine coverage
 1using UnityEngine.Audio;
 2using System;
 3using UnityEngine;
 4
 5public class AudioManager : MonoBehaviour
 6{
 7
 8  public static AudioManager instance;
 9
 10  public AudioMixerGroup mixerGroup;
 11
 12  public Sound[] sounds;
 13
 14  void Awake()
 415  {
 416    if (instance != null)
 017    {
 018      Destroy(gameObject);
 019    }
 20    else
 421    {
 422      instance = this;
 423      DontDestroyOnLoad(gameObject);
 424    }
 25
 3626    foreach (Sound s in sounds)
 1227    {
 1228      s.source = gameObject.AddComponent<AudioSource>();
 1229      s.source.clip = s.clip;
 1230      s.source.loop = s.loop;
 31
 1232      s.source.outputAudioMixerGroup = mixerGroup;
 1233    }
 434  }
 35
 36  public void Play(string sound)
 7437  {
 14838    Sound s = Array.Find(sounds, item => item.name == sound);
 7439    if (s == null)
 040    {
 041      Debug.LogWarning("Sound: " + name + " not found!");
 42      //return;
 043    }
 44
 7445    s.source.volume = s.volume * (1f + UnityEngine.Random.Range(-s.volumeVariance / 2f, s.volumeVariance / 2f));
 7446    s.source.pitch = s.pitch * (1f + UnityEngine.Random.Range(-s.pitchVariance / 2f, s.pitchVariance / 2f));
 47
 7448    s.source.Play();
 7449  }
 50
 51}

Methods/Properties

Awake()
Play(System.String)