Text pop up when mouse over gui button

Hi, I’m working on an inventory for my game and to make stuff take less space on the screen I decided to use pictures instead of text were the items are, now I only whant some text to show up at the mouse when hovering over the item in the inventory (Also show how much of it you got).

Here is some code that I´m using:

The Inventory script:

var targetScript: Player;

var Inventory = false;


var YellowFlowerButton : Texture;

function OnGUI(){
	if(Inventory){
		GUI.Box (Rect (0,0,Screen.height,Screen.width), "Inventory");
			if (GUI.Button (Rect (10,Screen.width/2,Screen.height/2.5,Screen.width/20), YellowFlowerButton)) {
				if(targetScript.shop == true){
					if(targetScript.YellowFlower >= 1){
						targetScript.YellowFlower -= 1;
						targetScript.YellowFlowers = "Yellow Flowers: " + targetScript.YellowFlower;
						targetScript.Coin += 2;
				}
			}
	}
}

The player script:

var YellowFlower : int;


//ITEM PICKUP
//YELLOW FLOWERS
@HideInInspector
var YellowFlowers = "Yellow Flowers: 0";
@HideInInspector
var YellowFlowerPick : GameObject = null;
@HideInInspector
var YellowFlowerPick2 = false;


function OnTriggerEnter(other : Collider){

	//ITEM PICKUP
	//YELLOW FLOWERS
	if(other.tag == "YellowFlower"){
		YellowFlowerPick = other.gameObject;
		YellowFlowerPick2 = true;
	}
	
}


function OnTriggerExit(other : Collider){
	
	//ITEM PICKUP
	//YELLOW FLOWER QUEST
	if(other.tag == "YellowFlower"){
		YellowFlowerPick = null;
		YellowFlowerPick2 = false;
	}
}


function Update(){
    
    //ITEM PICKUP
    
    //YELLOW FLOWERS
    if(YellowFlowerPick != null){
        if(Input.GetButtonDown("Interact")){
            YellowFlower += 1;
            Destroy(YellowFlowerPick);
            YellowFlowerPick2 = false;
            YellowFlowers = "Yellow Flowers: " + YellowFlower;
        }
    }
}

function OnGUI(){
	
	//ITEM PICKUP
	
	//YELLOW FLOWERS
	if(YellowFlowerPick2 == true){
		GUI.Box (Rect (Screen.height+(Screen.height/17),Screen.width/2-(Screen.width/9),Screen.height/3,Screen.width/30), "

Press E to take Yellow Flower");
}
}

This is only the code that has with the inventory and item pick up to do!

So if someone that is better at coding then I am I could really do with some help! (And I’m really sure there is lots of people out there that is… xD)

Tnx! :slight_smile:

//Elis

You want a tool tip Unity - Scripting API: GUI.tooltip sorry it’s just a link, I despise unity’s GUI.

The only thing I could say is that rather than using:

void OnTriggerEnter ()

you could use:

void OnMouseOver()

Which you can learn more about here: http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseOver.html

Also, I’m not sure if you’re interested, but there is a third party tool that can be added to Unity which makes GUI so much easier. If oyu are interested, you can see it here: http://www.tasharen.com/?page_id=140

And you can see videos on it here: http://cgcookie.com/unity/cgc-courses/getting-started-with-ngui-for-unity/