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), "\nPress 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! ![]()
//Elis