Hi everyone, i am having trouble trying to show the description of an specific item… i want that when the user opens the inventory and clicks on the item´s button it shows the description of that item, thanks for your time, i have this code:
`public class Inventory : MonoBehaviour {
//Holding of items
public Items[] items;
//Inventory
private Rect InventoryWindows = new Rect (300, 100, 400, 400);
public List<Items> MainInventory = new List<Items>();
public bool InventoryOpen = false;
public bool GUIEnabled = false;
public bool descriptionOn = false;
void Start(){
MainInventory.Add (items [0]);
MainInventory.Add (items [1]);
}
public void Update(){
if (Input.GetKeyDown ("i")) {
Screen.lockCursor = false;
GUIEnabled = !GUIEnabled;
InventoryOpen = true;
}
else if (Input.GetKeyDown ("i") && InventoryOpen == true) {
Screen.lockCursor = true;
}
}
public void OnGUI() {
if (GUIEnabled) {
InventoryWindows = GUI.Window(0,InventoryWindows,InventoryWindowmethod,"Inventory");
}
if (descriptionOn) {
InventoryWindows = GUI.Window(0,InventoryWindows,InventoryWindowDescription,"Description");
}
}
void InventoryWindowmethod(int WindowsId){
GUILayout.BeginArea (new Rect (5, 50, 390, 400));
GUILayout.BeginHorizontal ();
if (GUILayout.Button (MainInventory [0].Name, GUILayout.Height (50))) {
descriptionOn = true;
}
if (GUILayout.Button (MainInventory [1].Name, GUILayout.Height (50))) {
descriptionOn = true;
}
GUILayout.EndHorizontal ();
GUILayout.EndArea ();
}
void InventoryWindowDescription(int Windows){
GUILayout.BeginArea(new Rect(5,50,390,400));
GUILayout.BeginHorizontal();
if (GUILayout.Button (MainInventory[0].Description, GUILayout.Height (50))) {
descriptionOn = false;
}
GUILayout.EndHorizontal();
GUILayout.EndArea ();
}
}
`
edit: (to clear things out)
the code will show me the item description but only the first item description because the code is written to do so, but i want that when the user clicks on the second item the new gui button shows that description not the first one, but i dont know how to write that.