< Summary

Class:ToggleParticle
Assembly:Test
File(s):E:/Unity/Unity Project/VR-Room/Assets/_Course Library/Scripts/Test/ToggleParticle.cs
Covered lines:31
Uncovered lines:8
Coverable lines:39
Total lines:62
Line coverage:79.4% (31 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%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()
 418    {
 419        currentParticleSystem.Play();
 420    }
 21
 22    public void Stop()
 323    {
 324        currentParticleSystem.Stop();
 325    }
 26
 27    public void PlayWithExclusivity(MonoBehaviour owner)
 128    {
 129        if(currentOwner == null)
 130        {
 131            currentOwner = this;
 132            Play();
 133        }
 134    }
 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()
 855    {
 856        if(currentParticleSystem.isPlaying)
 557        {
 558            currentParticleSystem.Stop();
 559        }
 360        else currentParticleSystem.Play();
 861    }
 62}