< Summary

Class:ButtonVR
Assembly:Test
File(s):D:/--UnityProject/VR/VRExplorer_subjects/VR-Adventure/Assets/Scripts/ButtonVR.cs
Covered lines:26
Uncovered lines:0
Coverable lines:26
Total lines:64
Line coverage:100% (26 of 26)
Covered branches:0
Total branches:0
Covered methods:4
Total methods:4
Method coverage:100% (4 of 4)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Start()0%000100%
OnTriggerEnter(...)0%000100%
OnTriggerExit(...)0%000100%
SpawnSphere()0%000100%

File(s)

D:/--UnityProject/VR/VRExplorer_subjects/VR-Adventure/Assets/Scripts/ButtonVR.cs

#LineLine coverage
 1using BNG;
 2using System.Collections;
 3using System.Collections.Generic;
 4using System.Diagnostics.CodeAnalysis;
 5using UnityEngine;
 6using UnityEngine.Events;
 7using VRExplorer;
 8public class ButtonVR : MonoBehaviour, ITriggerableEntity
 9{
 10    [ExcludeFromCodeCoverage] public float TriggeringTime => 1.5f;
 11    [ExcludeFromCodeCoverage] public string Name => Str.Triggerable;
 12
 13    [ExcludeFromCodeCoverage]
 14    public void Triggerring()
 15    {
 16        onPress?.Invoke();
 17    }
 18
 19    [ExcludeFromCodeCoverage]
 20    public void Triggerred()
 21    {
 22        onRelease?.Invoke();
 23    }
 24
 25    public GameObject button;
 26    public UnityEvent onPress;
 27    public UnityEvent onRelease;
 28    GameObject presser;
 29    bool isPressed;
 30
 31    void Start()
 832    {
 833        isPressed = false;
 834    }
 35
 36    private void OnTriggerEnter(Collider other)
 337    {
 338        if(!isPressed)
 339        {
 340            button.transform.localPosition = new Vector3(-0.52f, 0.279f, -0.133f);
 341            presser = other.gameObject;
 342            onPress.Invoke();
 343            isPressed = true;
 344        }
 345    }
 46
 47    private void OnTriggerExit(Collider other)
 348    {
 349        if(other.gameObject == presser)
 350        {
 351            button.transform.localPosition = new Vector3(-0.544f, 0.279f, -0.133f);
 352            onRelease.Invoke();
 353            isPressed = false;
 354        }
 355    }
 56
 57    public void SpawnSphere()
 658    {
 659        GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
 660        sphere.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
 661        sphere.transform.localPosition = new Vector3(-0.98f, -0.18f, 0.4f);
 662        sphere.AddComponent<Rigidbody>();
 663    }
 64}