using UnityEngine; using TMPro; public class UsbInteractable : MonoBehaviour { public GameObject interactionHintUI; // Reference to UI text public Item itemToAddToInventory; // ScriptableObject item to add private bool isMouseHovering = false; void OnMouseEnter() { interactionHintUI.SetActive(true); interactionHintUI.GetComponent().text = $"Left-click to download {itemToAddToInventory.itemName} to tablet"; isMouseHovering = true; Debug.Log($"Mouse entered USB for {itemToAddToInventory.itemName}. Showing hint."); } void OnMouseExit() { interactionHintUI.SetActive(false); isMouseHovering = false; Debug.Log($"Mouse exited USB for {itemToAddToInventory.itemName}. Hiding hint."); } void Update() { if (isMouseHovering && Input.GetMouseButtonDown(0)) { Debug.Log($"Downloaded {itemToAddToInventory.itemName} to inventory."); interactionHintUI.SetActive(false); // Add to Inventory var inventory = FindObjectOfType(); if (inventory != null) { inventory.AddItem(itemToAddToInventory); } // Hide USB object from scene gameObject.SetActive(false); } } }