I’m not doing very well when it comes to scripting in Unity, and I’d like to make Skyrim-style object descriptions, when you aim your cursor at an object. For example: you have a door leading to another cell/level, and when you aim at them name of the cell displays, and for example “‘Assigned_key’ to enter”; when you aim at an object you can pick up, it shows you it’s name and “‘Assigned_key’ to pick up”. Also object that has interaction option: Name and “‘Assigned_key’ to interact”. I realise that nobody will give me an entire solution, but some leads would be great! Thanks in advance.
// here is the idea. attach this to your object you where aiming
bool hover = false;
Vector3 pos;
void OnMouseEnter()
{
hover = true;
pos = Camera.main.WorldToScreenPoint(transform.position);
pos.y = Screen.height - pos.y;
}
void OnMouseExit()
{
hover = false;
}
void OnGUI()
{
float btnWidth = 100;
float btnHeight = 25;
if (hover && GUI.Button(new Rect(pos.x - btnWidth / 2,pos.y - btnHeight / 2, btnWidth, btnHeight),"Click"))
{
Debug.Log("Clicked");
}
}