< Summary

Class:MatchRotation
Assembly:Test
File(s):E:/Unity/Unity Project/VR-Basics/Assets/_Course Library/Scripts/Core/MatchRotation.cs
Covered lines:15
Uncovered lines:0
Coverable lines:15
Total lines:36
Line coverage:100% (15 of 15)
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
MatchRotation()0%000100%
Awake()0%000100%
FollowRotation()0%000100%

File(s)

E:/Unity/Unity Project/VR-Basics/Assets/_Course Library/Scripts/Core/MatchRotation.cs

#LineLine coverage
 1using UnityEngine;
 2
 3/// <summary>
 4/// Match the rotation of the target transform
 5/// </summary>
 6public class MatchRotation : MonoBehaviour
 7{
 8    [Tooltip("Match x rotation")]
 29    public bool matchX = false;
 10
 11    [Tooltip("Match y rotation")]
 212    public bool matchY = false;
 13
 14    [Tooltip("Match z rotation")]
 215    public bool matchZ = false;
 16
 17    [Tooltip("The transform this object will match")]
 218    public Transform targetTransform = null;
 219    private Vector3 originalRotation = Vector3.zero;
 20
 21    private void Awake()
 122    {
 123        originalRotation = transform.eulerAngles;
 124    }
 25
 26    public void FollowRotation()
 527    {
 528        Vector3 newRotation = targetTransform.eulerAngles;
 29
 530        newRotation.x = matchX ? newRotation.x : originalRotation.x;
 531        newRotation.y = matchY ? newRotation.y : originalRotation.y;
 532        newRotation.z = matchZ ? newRotation.z : originalRotation.z;
 33
 534        transform.rotation = Quaternion.Euler(newRotation);
 535    }
 36}