< Summary

Class:ToggleParticle
Assembly:Test
File(s):E:/Unity/Unity Project/VR-Room/Assets/_Course Library/Scripts/Test/ToggleParticle.cs
Covered lines:15
Uncovered lines:24
Coverable lines:39
Total lines:62
Line coverage:38.4% (15 of 39)
Covered branches:0
Total branches:0
Covered methods:4
Total methods:8
Method coverage:50% (4 of 8)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ToggleParticle()0%000100%
Awake()0%000100%
Play()0%0000%
Stop()0%0000%
PlayWithExclusivity(...)0%0000%
StopWithExclusivity(...)0%0000%
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()
 018    {
 019        currentParticleSystem.Play();
 020    }
 21
 22    public void Stop()
 023    {
 024        currentParticleSystem.Stop();
 025    }
 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)
 037    {
 038        if(currentOwner == this)
 039        {
 040            currentOwner = null;
 041            Stop();
 042        }
 043    }
 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()
 455    {
 456        if(currentParticleSystem.isPlaying)
 357        {
 358            currentParticleSystem.Stop();
 359        }
 160        else currentParticleSystem.Play();
 461    }
 62}