using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using TMPro; /* -------------------------------------- Project: Programing assessment Standard: 91906 (AS3.7) v.1 School: Tauranga Boys' College Author: Rauputu Noah Phizacklea Date: August 2024 Unity: 2021.3.18f --------------------------------------- */ public class ToolTipManager : MonoBehaviour { public static ToolTipManager currentInstance; // Singleton instance of ToolTipManager public TextMeshProUGUI toolTipText; // Text component to display the tooltip message // Awake is called when the script instance is being loaded void Awake() { // Manage singleton pattern to ensure only one instance of ToolTipManager exists if (currentInstance != null && currentInstance != this) { Destroy(this.gameObject); } else { currentInstance = this; } } // Start is called before the first frame update void Start() { Cursor.visible = true; // Ensure the cursor is visible gameObject.SetActive(false); // Initially hide the tooltip } // Update is called once per frame void Update() { // Update the position of the tooltip to follow the mouse cursor transform.position = Input.mousePosition; } // Show the tooltip with the given message public void SetAndShowToolTip(string message) { gameObject.SetActive(true); // Make the tooltip visible toolTipText.text = message; // Set the message text } // Hide the tooltip public void HideToolTip() { gameObject.SetActive(false); // Hide the tooltip toolTipText.text = ""; // Clear the message text } }