< Summary

Class:ToggleParticle
Assembly:Test
File(s):D:/--UnityProject/VR/VRExplorer_subjects/VR-Room/Assets/_Course Library/Scripts/Test/ToggleParticle.cs
Covered lines:28
Uncovered lines:11
Coverable lines:39
Total lines:62
Line coverage:71.7% (28 of 39)
Covered branches:0
Total branches:0
Covered methods:8
Total methods:8
Method coverage:100% (8 of 8)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ToggleParticle()0%000100%
Awake()0%000100%
Play()0%000100%
Stop()0%000100%
PlayWithExclusivity(...)0%000100%
StopWithExclusivity(...)0%00042.86%
OnValidate()0%00042.86%
ToggleParticleSystem()0%00057.14%

File(s)

D:/--UnityProject/VR/VRExplorer_subjects/VR-Room/Assets/_Course Library/Scripts/Test/ToggleParticle.cs

#LineLine coverage
 1using UnityEngine;
 2
 3/// <summary>
 4/// Toggles particle system
 5/// </summary>
 6[RequireComponent(typeof(ParticleSystem))]
 7public class ToggleParticle : MonoBehaviour
 8{
 109    private ParticleSystem currentParticleSystem = null;
 1010    private MonoBehaviour currentOwner = null;
 11
 12    private void Awake()
 813    {
 814        currentParticleSystem = GetComponent<ParticleSystem>();
 815    }
 16
 17    public void Play()
 418    {
 419        currentParticleSystem.Play();
 420    }
 21
 22    public void Stop()
 223    {
 224        currentParticleSystem.Stop();
 225    }
 26
 27    public void PlayWithExclusivity(MonoBehaviour owner)
 228    {
 229        if(currentOwner == null)
 230        {
 231            currentOwner = this;
 232            Play();
 233        }
 234    }
 35
 36    public void StopWithExclusivity(MonoBehaviour owner)
 237    {
 238        if(currentOwner == this)
 039        {
 040            currentOwner = null;
 041            Stop();
 042        }
 243    }
 44
 45    private void OnValidate()
 1046    {
 1047        if(currentParticleSystem)
 048        {
 049            ParticleSystem.MainModule main = currentParticleSystem.main;
 050            main.playOnAwake = false;
 051        }
 1052    }
 53
 54    public void ToggleParticleSystem()
 255    {
 256        if(currentParticleSystem.isPlaying)
 057        {
 058            currentParticleSystem.Stop();
 059        }
 260        else currentParticleSystem.Play();
 261    }
 62}