< Summary

Class:Collectable
Assembly:Test
File(s):E:/Unity/Unity Project/EscapeTheRoomVR/Assets/Test 1/Collectable.cs
Covered lines:19
Uncovered lines:4
Coverable lines:23
Total lines:43
Line coverage:82.6% (19 of 23)
Covered branches:0
Total branches:0
Covered methods:4
Total methods:4
Method coverage:100% (4 of 4)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%00062.5%
Start()0%000100%
Collect()0%00080%
SetGazedAt(...)0%000100%

File(s)

E:/Unity/Unity Project/EscapeTheRoomVR/Assets/Test 1/Collectable.cs

#LineLine coverage
 1using System.Collections;
 2using System.Collections.Generic;
 3using UnityEngine;
 4using UnityEngine.UI;
 5using UnityEngine.Events;
 6
 7public class Collectable : MonoBehaviour {
 8  public Item item; // The object that will go into the inventory when this is picked up
 9  private Inventory inventory;
 10    public Material inactiveMaterial; // Default material for item (when not pointing at it)
 11    public Material gazedAtMaterial; // Highlight material for item (to show it's inspectable)
 12    public UnityEvent dispatch; // Callback
 13
 1014  void Awake() {
 1015    Debug.Log("init collectable");
 1016    inventory = FindObjectOfType<Inventory>();
 1017    if (inventory == null) {
 018      Debug.Log("Couldn't find inventory!");
 019    }
 1020  }
 21
 922  void Start() {
 923    SetGazedAt(false);
 924  }
 25
 726  public void Collect() {
 927        if (item) {
 228            Debug.Log("Picked up " + item.name + "!");
 29            // Add item to inventory and remove item from scene
 230            inventory.AddItem(item);
 031            GameObject.Destroy(gameObject);
 032        }
 1033        if (dispatch != null) dispatch.Invoke(); // Callback
 534  }
 35
 1136  public void SetGazedAt(bool gazedAt) {
 37        // Show material corresponding to controller's laser pointer location
 2238    if (inactiveMaterial != null && gazedAtMaterial != null) {
 1139      GetComponent<Renderer>().material = gazedAt ? gazedAtMaterial : inactiveMaterial;
 1140      return;
 41    }
 1142  }
 43}