using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; public class StationaryDefectDetector : MonoBehaviour, IResetable { public List _knownProducts; public AudioClip goodSound; public AudioClip badSound; public void ResetMachine() { _knownProducts.Clear(); } private void OnTriggerEnter(Collider other) { var product = other.GetComponentInParent(); if (product == null) { return; } if (_knownProducts.Contains(product)) { return; } _knownProducts.Add(product); NAudio.Play(product.Defect == DefectType.None ? goodSound : badSound, transform.position); } private void OnTriggerExit(Collider other) { if (other.TryGetComponent(out Product product)) { if (_knownProducts.Contains(product)) { _knownProducts.Remove(product); } } } }