< Summary

Class:ToggleActiveGameObject
Assembly:UIHelpers
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Helpers/UIHelpers/ToggleActiveGameObject.cs
Covered lines:9
Uncovered lines:0
Coverable lines:9
Total lines:27
Line coverage:100% (9 of 9)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%110100%
Start()0%110100%
UpdateState(...)0%330100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Helpers/UIHelpers/ToggleActiveGameObject.cs

#LineLine coverage
 1using UnityEngine;
 2using UnityEngine.UI;
 3
 4[RequireComponent(typeof(Toggle))]
 5public class ToggleActiveGameObject : MonoBehaviour
 6{
 7    [SerializeField] GameObject activeOn = null;
 8    [SerializeField] GameObject activeOff = null;
 9
 10    private Toggle targetToggle;
 11
 12    private void Awake()
 13    {
 3214        targetToggle = GetComponent<Toggle>();
 3215        targetToggle.onValueChanged.AddListener(UpdateState);
 3216    }
 17
 1418    protected void Start() { UpdateState(targetToggle.isOn); }
 19
 20    private void UpdateState(bool isOn)
 21    {
 1522        if (activeOn)
 1523            activeOn.gameObject.SetActive(isOn);
 1524        if (activeOff)
 1525            activeOff.gameObject.SetActive(!isOn);
 1526    }
 27}