I’m trying to learn how to use Unity without copying scripts, so far I’m just trying to make a Inventory screen show up on key press, and Iv’e been looking around through the forums to figure out how to bring up a GUI when a key is pressed, but their all written in Javascript, I decided C# would be better since I could use it with other engines. Anyways this is the script I came up with
using UnityEngine;
using System.Collections;
public class InventoryGUI : MonoBehaviour {
private bool showInventory = false;
private bool inventoryKey = Input.GetKeyDown(KeyCode.I);
// Use this for initialization
void Start () {
}
// Update is called once per frame
void OnGUI () {
if(showInventory = false;)
{
GUI.Box(new Rect(80, 50, 400, 200), "Inventory");
}
else{
while(inventoryKey)
{
GUI.Box(new Rect(80, 50, 400, 200), "Inventory");
}
}
}
}
I got it to one point where it popped up on play but not when you press a key, I feel kind of stupid for not being able to figure this out. Am I going in the right direction with this?