using UnityEngine; using RaycastPro; using RaycastPro.RaySensors; using StarterAssets; using Unity.VisualScripting; public class InteractionManager : MonoBehaviour { StarterAssetsInputs starterAssetsInputs; [SerializeField] GameObject player; [SerializeField] PopUpManager popUpManager; GameObject currentInteractable; [SerializeField] BasicRay interactionRay; void Awake() { starterAssetsInputs = player.GetComponent(); } void Update() { if(starterAssetsInputs.interact) { TriggerInteraction(); } } public void TriggerInteraction() { bool isPopUpActive = popUpManager.IsPopUpActive(); if (isPopUpActive && currentInteractable != null) { currentInteractable.GetComponent()?.OnInteract(); } starterAssetsInputs.InteractInput(false); // Reset the interact input after handling } public void AssignInteractable() { currentInteractable = interactionRay.Hit.transform.gameObject; popUpManager.ShowPopUp(); } public void ClearInteractable() { currentInteractable = null; popUpManager.HidePopUp(); } public void CheckLights() { if(currentInteractable != null) { Light light = currentInteractable.GetComponent(); if (light != null) { Debug.Log("Interacted with a light: " + light.name); } } } }