So im working on this text where when you hover over it, it tells you what it is for example when you hover over a tree a text saying (Oak Tree) will pop up. But every-time i go to add this to my empty object it says, “Can’t add script behaviour ‘SelectionManager’. The script needs to derive from MonoBehaviour!” All of the names in my scene and Script match up does anyone know whats wrong? I will paste the script below. V
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SelectionManager : MonoBehaviour
{
public GameObject interaction_info_UI;
Text interaction_text;
private void Start()
{
interaction_text = interaction_info_UI.GetComponent<Text>();
}
void Update()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
var selectionTransform = hit.transform;
if (selectionTransform.GetComponent<InteractableObject>())
{
interaction_text.text = selectionTransform.GetComponent<InteractableObject>().GetItemName();
interaction_info_UI.SetActive(true);
}
else
{
interaction_info_UI.SetActive(false);
}
}
}
}