< Summary

Class:MatchRotation
Assembly:Test
File(s):D:/--UnityProject/VR/_____ISSTA 26/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)

D:/--UnityProject/VR/_____ISSTA 26/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")]
 49    public bool matchX = false;
 10
 11    [Tooltip("Match y rotation")]
 412    public bool matchY = false;
 13
 14    [Tooltip("Match z rotation")]
 415    public bool matchZ = false;
 16
 17    [Tooltip("The transform this object will match")]
 418    public Transform targetTransform = null;
 419    private Vector3 originalRotation = Vector3.zero;
 20
 21    private void Awake()
 222    {
 223        originalRotation = transform.eulerAngles;
 224    }
 25
 26    public void FollowRotation()
 427    {
 428        Vector3 newRotation = targetTransform.eulerAngles;
 29
 430        newRotation.x = matchX ? newRotation.x : originalRotation.x;
 431        newRotation.y = matchY ? newRotation.y : originalRotation.y;
 432        newRotation.z = matchZ ? newRotation.z : originalRotation.z;
 33
 434        transform.rotation = Quaternion.Euler(newRotation);
 435    }
 36}