Inventory not displaying when being told to do so [C#]

Hey guys, I am punching the “e” key which should tell the script to display the Inventory, but it doesn’t.

Anyone wanna take a crack at it? Thanks!

using UnityEngine;
using System.Collections;

public class GUIController : MonoBehaviour {
	
	public bool shower = false;
	public Texture2D myTexture;
	
	void ShowInv () {
		GUI.enabled = true;
	}
	
	void HideInv () {
		GUI.enabled = false;
	}
	
	void Start () {
	
	}
	
	void Update () {
		if (Input.GetKeyUp("e") && shower == false){
			shower = true;
			ShowInv();
		}
		
		if (Input.GetKeyUp("e") && shower == true){
			shower = false;
			HideInv();
		}
		
		if (shower == true){
			GUI.skin.box.normal.background = myTexture;
			GUI.Box(new Rect(Screen.width/2, Screen.height/2, 128, 128), "Inventory");
		}
	}
}

I don’t know why you are not using OnGUI(), or how you are not getting errors setting GUI.enabled, but this is generally done by setting a boolean (like you do but forget GUI.enabled)
Something like:

void OnGUI()
{
  if (shower)
  {
 ... put your GUI. functions here
  }
}

You can simplify your code a bit:

void Update()
{
    if (Input.GetKeyDown("e"))
      shower = !shower;
}

void Update () {
if (Input.GetKeyUp(“e”)){
shower = !true;
}
}

That will always be false. Change it to

 void Update () {
if (Input.GetKeyUp("e")){
shower = !shower;
}
}

A slight alteration here may work:

void Update() {
    if (Input.GetKeyUp("e")){
        if (shower){
            shower = false;
        } else {
            shower = true;
        }
    }
}

Try this, see if it helps :smiley: