< Summary

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

D:/--UnityProject/VR/_____ISSTA 26/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
 2014  void Awake() {
 2015    Debug.Log("init collectable");
 2016    inventory = FindObjectOfType<Inventory>();
 2017    if (inventory == null) {
 018      Debug.Log("Couldn't find inventory!");
 019    }
 2020  }
 21
 1822  void Start() {
 1823    SetGazedAt(false);
 1824  }
 25
 626  public void Collect() {
 827        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        }
 833        if (dispatch != null) dispatch.Invoke(); // Callback
 434  }
 35
 2136  public void SetGazedAt(bool gazedAt) {
 37        // Show material corresponding to controller's laser pointer location
 4238    if (inactiveMaterial != null && gazedAtMaterial != null) {
 2139      GetComponent<Renderer>().material = gazedAt ? gazedAtMaterial : inactiveMaterial;
 2140      return;
 41    }
 2142  }
 43}