This is the script I’m trying to get to work when hover over a object like a button in the game world if anyone could help me?
using UnityEngine;
using System.Collections;
public class button : MonoBehaviour {
void GUI() {
GUI.Label(new Rect (25, 25, 100, 30), "E to open Or Close");
}
}
Hope this one help you at least a little and good luck
using UnityEngine;
using System.Collections;
public class New : MonoBehaviour {
void OnGUI()
{
GUILayout.BeginVertical();
GUILayout.Button("First");
GUILayout.Button("Second");
GUILayout.Button("Third");
GUILayout.EndVertical();
if(Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition ))
{
GUI.Label(new Rect(225, 225, 128, 48), "E to open Or Close");
}
}
}
- Create new scene in new project
- Add new C# script and name it “New”
- Copy paste script
- Add script to main camera
- Play and enjoy
- Don’t forget to come back and tell how it went