< Summary

Class:BallBounce
Assembly:Test
File(s):E:/Unity/Unity Project/VR-Room/Assets/_Course Library/Scripts/Test/BallBounce.cs
Covered lines:7
Uncovered lines:3
Coverable lines:10
Total lines:51
Line coverage:70% (7 of 10)
Covered branches:0
Total branches:0
Covered methods:2
Total methods:2
Method coverage:100% (2 of 2)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Start()0%000100%
OnCollisionEnter(...)0%00050%

File(s)

E:/Unity/Unity Project/VR-Room/Assets/_Course Library/Scripts/Test/BallBounce.cs

#LineLine coverage
 1using BNG;
 2using System.Diagnostics.CodeAnalysis;
 3using UnityEngine;
 4using HenryLab;
 5
 6[RequireComponent(typeof(AudioSource))]
 7public class BallBounce : MonoBehaviour, IGrabbableEntity
 8{
 9    [ExcludeFromCodeCoverage]
 10    public Grabbable Grabbable
 11    {
 12        get
 13        {
 14            var g = GetComponent<Grabbable>();
 15            if (g) return g;
 16            return gameObject.AddComponent<Grabbable>();
 17        }
 18    }
 19    [ExcludeFromCodeCoverage] public Transform Destination => null;
 20
 21    [ExcludeFromCodeCoverage] public string Name => Str.Grabbable;
 22
 23    [ExcludeFromCodeCoverage]
 24    public void OnGrabbed()
 25    {
 26    }
 27
 28    [ExcludeFromCodeCoverage]
 29    public void OnReleased()
 30    {
 31    }
 32
 33    public AudioClip collisionSound; // Sound clip for ball collision
 34
 35    private AudioSource audioSource; // Reference to the AudioSource component
 36
 37    private void Start()
 138    {
 139        audioSource = GetComponent<AudioSource>();
 140        audioSource.clip = collisionSound;
 141    }
 42
 43    private void OnCollisionEnter(Collision collision)
 444    {
 45        // Play the collision sound if a collision occurs
 446        if (collision.relativeVelocity.magnitude > 0.5f)
 047        {
 048            audioSource.PlayOneShot(collisionSound);
 049        }
 450    }
 51}