< Summary

Class:VRNoPeeking
Assembly:Test
File(s):D:/--UnityProject/VR/VRExplorer_subjects/EscapeGameVR/Assets/Scripts/Test/VR/VRNoPeeking.cs
Covered lines:2
Uncovered lines:27
Coverable lines:29
Total lines:52
Line coverage:6.8% (2 of 29)
Covered branches:0
Total branches:0
Covered methods:1
Total methods:5
Method coverage:20% (1 of 5)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
VRNoPeeking()0%000100%
Awake()0%0000%
Update()0%0000%
CameraFade(...)0%0000%
IsCameraFadedOut()0%0000%

File(s)

D:/--UnityProject/VR/VRExplorer_subjects/EscapeGameVR/Assets/Scripts/Test/VR/VRNoPeeking.cs

#LineLine coverage
 1using System.Collections;
 2using System.Collections.Generic;
 3using UnityEngine;
 4
 5public class VRNoPeeking : MonoBehaviour
 6{
 7    [SerializeField] LayerMask collisionLayer;
 8    [SerializeField] float fadeSpeed;
 129    [SerializeField] float sphereCheckSize = 0.15f;
 10
 11    private Material cameraFadeMat;
 1212    private bool isCameraFadedOut = false;
 13
 14    private void Awake()
 015    {
 016        cameraFadeMat = GetComponent<Renderer>().material;
 017    }
 18
 19    // Update is called once per frame
 20    void Update()
 021    {
 022        if (Physics.CheckSphere(transform.position, sphereCheckSize, collisionLayer, QueryTriggerInteraction.Ignore))
 023        {
 024            CameraFade(1f);
 025            isCameraFadedOut = true;
 026        }
 27        else
 028        {
 029            if(!isCameraFadedOut)
 030            {
 031                return;
 32            }
 033            CameraFade(0f);
 034        }
 035    }
 36
 37    public void CameraFade(float targetAlpha)
 038    {
 039        var fadeValue = Mathf.MoveTowards(cameraFadeMat.GetFloat("_AlphaValue"), targetAlpha, Time.deltaTime * fadeSpeed
 040        cameraFadeMat.SetFloat("_AlphaValue", fadeValue);
 41
 042        if(fadeValue <= 0.01f)
 043        {
 044            isCameraFadedOut = false;
 045        }
 046    }
 47
 48    public bool IsCameraFadedOut()
 049    {
 050        return isCameraFadedOut;
 051    }
 52}