using UnityEngine; public class Collectible : MonoBehaviour { [SerializeField] private int scoreValue = 1; [SerializeField] private bool destroyOnPickup = true; private void OnTriggerEnter(Collider other) { if (!other.CompareTag("Player")) { return; } UIManager uiManager = FindObjectOfType(); if (uiManager != null) { uiManager.AddScore(scoreValue); } Debug.Log($"Collected {name} for {scoreValue} point(s)."); if (destroyOnPickup) { Destroy(gameObject); } else { gameObject.SetActive(false); } } }