< 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()
 115  {
 116    if (instance != null)
 017    {
 018      Destroy(gameObject);
 019    }
 20    else
 121    {
 122      instance = this;
 123      DontDestroyOnLoad(gameObject);
 124    }
 25
 926    foreach (Sound s in sounds)
 327    {
 328      s.source = gameObject.AddComponent<AudioSource>();
 329      s.source.clip = s.clip;
 330      s.source.loop = s.loop;
 31
 332      s.source.outputAudioMixerGroup = mixerGroup;
 333    }
 134  }
 35
 36  public void Play(string sound)
 5337  {
 11138    Sound s = Array.Find(sounds, item => item.name == sound);
 5339    if (s == null)
 040    {
 041      Debug.LogWarning("Sound: " + name + " not found!");
 42      //return;
 043    }
 44
 5345    s.source.volume = s.volume * (1f + UnityEngine.Random.Range(-s.volumeVariance / 2f, s.volumeVariance / 2f));
 5346    s.source.pitch = s.pitch * (1f + UnityEngine.Random.Range(-s.pitchVariance / 2f, s.pitchVariance / 2f));
 47
 5348    s.source.Play();
 5349  }
 50
 51}

Methods/Properties

Awake()
Play(System.String)