< Summary

Class:MouseFollow
Assembly:Test
File(s):E:/Unity/Unity Project/vr-firefighter-simulator/Assets/Test/MouseFollow.cs
Covered lines:7
Uncovered lines:4
Coverable lines:11
Total lines:38
Line coverage:63.6% (7 of 11)
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
MouseFollow()0%000100%
Awake()0%000100%
Update()0%00042.86%

File(s)

E:/Unity/Unity Project/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()
 2212520    {
 21        // Work only in the editor in play mode as a debug
 22        // Player must hold right click to enable
 23#if UNITY_EDITOR
 2212524        if (EditorApplication.isPlaying && Input.GetMouseButton(1))
 025        {
 026            Cursor.lockState = CursorLockMode.Locked;
 027            this.HandleMouseInput();
 028        }
 29#endif
 2212530    }
 31
 32    void HandleMouseInput()
 33    {
 34        this.yaw += this.sensitivity * Input.GetAxis("Mouse X");
 35        this.pitch -= this.sensitivity * Input.GetAxis("Mouse Y");
 36        this.cam.transform.eulerAngles = new Vector3(this.pitch, this.yaw, 0f);
 37    }
 38}

Methods/Properties

MouseFollow()
Awake()
Update()