< Summary

Class:ToggleParticle
Assembly:Test
File(s):E:/Unity/Unity Project/VR-Room/Assets/_Course Library/Scripts/Test/ToggleParticle.cs
Covered lines:24
Uncovered lines:15
Coverable lines:39
Total lines:62
Line coverage:61.5% (24 of 39)
Covered branches:0
Total branches:0
Covered methods:7
Total methods:8
Method coverage:87.5% (7 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%0000%
StopWithExclusivity(...)0%00042.86%
OnValidate()0%00042.86%
ToggleParticleSystem()0%000100%

File(s)

E:/Unity/Unity Project/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{
 49    private ParticleSystem currentParticleSystem = null;
 410    private MonoBehaviour currentOwner = null;
 11
 12    private void Awake()
 213    {
 214        currentParticleSystem = GetComponent<ParticleSystem>();
 215    }
 16
 17    public void Play()
 218    {
 219        currentParticleSystem.Play();
 220    }
 21
 22    public void Stop()
 323    {
 324        currentParticleSystem.Stop();
 325    }
 26
 27    public void PlayWithExclusivity(MonoBehaviour owner)
 028    {
 029        if(currentOwner == null)
 030        {
 031            currentOwner = this;
 032            Play();
 033        }
 034    }
 35
 36    public void StopWithExclusivity(MonoBehaviour owner)
 137    {
 138        if(currentOwner == this)
 039        {
 040            currentOwner = null;
 041            Stop();
 042        }
 143    }
 44
 45    private void OnValidate()
 446    {
 447        if(currentParticleSystem)
 048        {
 049            ParticleSystem.MainModule main = currentParticleSystem.main;
 050            main.playOnAwake = false;
 051        }
 452    }
 53
 54    public void ToggleParticleSystem()
 755    {
 756        if(currentParticleSystem.isPlaying)
 257        {
 258            currentParticleSystem.Stop();
 259        }
 560        else currentParticleSystem.Play();
 761    }
 62}