< Summary

Class:SnapToTrigger
Assembly:Test
File(s):D:/--UnityProject/VR/VRExplorer_subjects/escapeVr/Assets/Script/room2/SnapToTrigger.cs
Covered lines:19
Uncovered lines:0
Coverable lines:19
Total lines:38
Line coverage:100% (19 of 19)
Covered branches:0
Total branches:0
Covered methods:3
Total methods:3
Method coverage:100% (3 of 3)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Start()0%000100%
Update()0%000100%
Snap(...)0%000100%

File(s)

D:/--UnityProject/VR/VRExplorer_subjects/escapeVr/Assets/Script/room2/SnapToTrigger.cs

#LineLine coverage
 1using System.Collections;
 2using System.Collections.Generic;
 3using UnityEngine;
 4using UnityEngine.XR.Interaction.Toolkit;
 5using UnityEngine.XR.Interaction.Toolkit.Transformers;
 6
 7public class SnapToTrigger : MonoBehaviour
 8{
 9    private XRGrabInteractable interactable;
 10    private XRGeneralGrabTransformer transformer;
 11    private Rigidbody rb;
 12    private bool isSnapped;
 13
 14    private void Start()
 2115    {
 2116        interactable = GetComponent<XRGrabInteractable>();
 2117        transformer = GetComponent<XRGeneralGrabTransformer>();
 2118        rb = GetComponent<Rigidbody>();
 2119    }
 20
 21    private void Update()
 1248122    {
 1248123        if (isSnapped)
 305524        {
 305525            gameObject.transform.RotateAroundLocal(new Vector3(0, 1, 0), 0.05f);
 305526        }
 1248127    }
 28
 29    public void Snap(Vector3 trigger_pos)
 430    {
 431        interactable.enabled = false;
 432        transformer.enabled = false;
 433        gameObject.transform.position = new Vector3(trigger_pos.x, trigger_pos.y + 0.4f, trigger_pos.z);
 434        gameObject.transform.rotation = new Quaternion(0, 0, 0, 0);
 435        rb.constraints = RigidbodyConstraints.FreezeAll;
 436        isSnapped = true;
 437    }
 38}