< Summary

Class:ToggleParticle
Assembly:Test
File(s):E:/Unity/Unity Project/VR-Room/Assets/_Course Library/Scripts/Test/ToggleParticle.cs
Covered lines:35
Uncovered lines:4
Coverable lines:39
Total lines:62
Line coverage:89.7% (35 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%000100%
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()
 618    {
 619        currentParticleSystem.Play();
 620    }
 21
 22    public void Stop()
 623    {
 624        currentParticleSystem.Stop();
 625    }
 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)
 337    {
 338        if(currentOwner == this)
 139        {
 140            currentOwner = null;
 141            Stop();
 142        }
 343    }
 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}