< Summary

Class:MouseFollow
Assembly:Test
File(s):D:/--UnityProject/VR/_____ISSTA 26/vr-firefighter-simulator/Assets/Test/MouseFollow.cs
Covered lines:7
Uncovered lines:9
Coverable lines:16
Total lines:38
Line coverage:43.7% (7 of 16)
Covered branches:0
Total branches:0
Covered methods:3
Total methods:4
Method coverage:75% (3 of 4)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
MouseFollow()0%000100%
Awake()0%000100%
Update()0%00042.86%
HandleMouseInput()0%0000%

File(s)

D:/--UnityProject/VR/_____ISSTA 26/vr-firefighter-simulator/Assets/Test/MouseFollow.cs

#LineLine coverage
 1using UnityEngine;
 2#if UNITY_EDITOR
 3using UnityEditor;
 4#endif
 5
 6public class MouseFollow : MonoBehaviour
 7{
 8    [Range(0f, 20f)]
 29    public float sensitivity = 10f;
 10    private float pitch;
 11    private float yaw;
 12    private Camera cam;
 13    void Awake()
 114    {
 115        this.cam = Camera.main;
 116    }
 17
 18    // Taken from https://stackoverflow.com/questions/66248977/camera-follow-player-when-moving-mouse-with-unity-3d
 19    void Update()
 1178920    {
 21        // Work only in the editor in play mode as a debug
 22        // Player must hold right click to enable
 23#if UNITY_EDITOR
 1178924        if (EditorApplication.isPlaying && Input.GetMouseButton(1))
 025        {
 026            Cursor.lockState = CursorLockMode.Locked;
 027            this.HandleMouseInput();
 028        }
 29#endif
 1178930    }
 31
 32    void HandleMouseInput()
 033    {
 034        this.yaw += this.sensitivity * Input.GetAxis("Mouse X");
 035        this.pitch -= this.sensitivity * Input.GetAxis("Mouse Y");
 036        this.cam.transform.eulerAngles = new Vector3(this.pitch, this.yaw, 0f);
 037    }
 38}