< 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")]
 59    public bool matchX = false;
 10
 11    [Tooltip("Match y rotation")]
 512    public bool matchY = false;
 13
 14    [Tooltip("Match z rotation")]
 515    public bool matchZ = false;
 16
 17    [Tooltip("The transform this object will match")]
 518    public Transform targetTransform = null;
 519    private Vector3 originalRotation = Vector3.zero;
 20
 21    private void Awake()
 222    {
 223        originalRotation = transform.eulerAngles;
 224    }
 25
 26    public void FollowRotation()
 227    {
 228        Vector3 newRotation = targetTransform.eulerAngles;
 29
 230        newRotation.x = matchX ? newRotation.x : originalRotation.x;
 231        newRotation.y = matchY ? newRotation.y : originalRotation.y;
 232        newRotation.z = matchZ ? newRotation.z : originalRotation.z;
 33
 234        transform.rotation = Quaternion.Euler(newRotation);
 235    }
 36}