< Summary

Class:SnapToTrigger
Assembly:Test
File(s):D:/--UnityProject/VR/_____ISSTA 26/escapeVr_VRAgent/Assets/Script/room2/SnapToTrigger.cs
Covered lines:8
Uncovered lines:11
Coverable lines:19
Total lines:38
Line coverage:42.1% (8 of 19)
Covered branches:0
Total branches:0
Covered methods:2
Total methods:3
Method coverage:66.6% (2 of 3)

Coverage History

Metrics

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

File(s)

D:/--UnityProject/VR/_____ISSTA 26/escapeVr_VRAgent/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()
 615    {
 616        interactable = GetComponent<XRGrabInteractable>();
 617        transformer = GetComponent<XRGeneralGrabTransformer>();
 618        rb = GetComponent<Rigidbody>();
 619    }
 20
 21    private void Update()
 723022    {
 723023        if (isSnapped)
 024        {
 025            gameObject.transform.RotateAroundLocal(new Vector3(0, 1, 0), 0.05f);
 026        }
 723027    }
 28
 29    public void Snap(Vector3 trigger_pos)
 030    {
 031        interactable.enabled = false;
 032        transformer.enabled = false;
 033        gameObject.transform.position = new Vector3(trigger_pos.x, trigger_pos.y + 0.4f, trigger_pos.z);
 034        gameObject.transform.rotation = new Quaternion(0, 0, 0, 0);
 035        rb.constraints = RigidbodyConstraints.FreezeAll;
 036        isSnapped = true;
 037    }
 38}