I want to make books (I have the 3D Models) that when they’re clicked on (in my inventory) they’ll display text on the screen. I have no IDEA how to do it - but here’s the script
private var playersInv : Inventory;
private var item : Item;
@script AddComponentMenu ("Inventory/Items/Item Effect")
@script RequireComponent(Item)
//This is where we find the components we need
function Awake ()
{
playersInv = FindObjectOfType(Inventory); //finding the players inv.
if (playersInv == null)
{
Debug.LogWarning("No 'Inventory' found in game. The Item " + transform.name + " has been disabled for pickup (canGet = false).");
}
item = GetComponent(Item);
}
//This is called when the object should be used.
function UseEffect ()
{
Debug.LogWarning("**<INSERT CUSTOM ACTION HERE>**"); //INSERT CUSTOM CODE HERE!
//Play a sound
playersInv.gameObject.SendMessage("PlayDropItemSound", SendMessageOptions.DontRequireReceiver);
//This will delete the item on use or remove 1 from the stack (if stackable).
if (deleteOnUse == true)
{
DeleteUsedItem();
}
}
//This takes care of deletion
function DeleteUsedItem()
{
if (item.stack == 1) //Remove item
{
playersInv.RemoveItem(this.gameObject.transform);
}
else //Remove from stack
{
item.stack -= 1;
}
Debug.Log(item.name + " has been deleted on use");
}
and the addon I’m using is here
If any of you smart people can come up with a script that will fit in between
function UseEffect ()
{
Debug.LogWarning(“”); //INSERT CUSTOM CODE HERE!
I would be so grateful.