I tried this script but seems my tooltip canvas can never be enabled.
The debug.logs come thru but canvas does not show while over game object with this script.
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class MouseOverPopUps : MonoBehaviour
{
// Place this script on any gameObject you want a tool tip for or MouseOver event
// I am working on thoughts for in game tool tips
// thinking of making preFabs for differant gameObject types,
// enemies, observers, quest givers..., differant house types...
[SerializeField] string popUpMessage = "Enter text title for this popup";
[SerializeField] TextMeshProUGUI textBox = null;
[SerializeField] Canvas inGameToolTipCanvas = null;
private void Awake() {
}
void OnMouseOver()
{
//If your mouse hovers over the GameObject with the script attached, output this message
Debug.Log($"Mouse is Over GameObject: {this.name} and its tag is {this.gameObject.tag}");
//if(textBox != null)
inGameToolTipCanvas.enabled = true;
textBox.text = $"Mouse over: {this.name} and its popUpMessage is {popUpMessage}";
}
void OnMouseExit()
{
//The mouse is no longer hovering over the GameObject so output this message each frame
Debug.Log($"Mouse has Exited the GameObject: {this.name} and its tag is {this.gameObject.tag}");
//if(textBox != null)
inGameToolTipCanvas.enabled = false;
textBox.text = "";
}
}
Any ideas?
Are there any game objects that can have text?
Thanks