so i have a script that does a few things currently, and it’s attached to an object in the scene. the problem is, neither the GUI button functions nor the code in update are running (nor the very simple code in start). i swear i’ve used this code before and it worked, so i don’t know what the problem is.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace CoS
{
public class heroInventory : MonoBehaviour
{
public Canvas hinventorycanvas;
public Button xbutton;
private int invcapacity = 50;
public string[,] inventory;
public Canvas hinvequippedcanvas;
public Button inviconbtn;
// Use this for initialization
void Start()
{
hinventorycanvas.enabled = false;
hinvequippedcanvas.enabled = false;
string[,] inventory = new string[invcapacity, 16];
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.I))
{
hinvequippedcanvas.enabled = !hinvequippedcanvas.enabled;
}
}
private void OnGUI()
{
if (xbutton)
{
hinventorycanvas.enabled = false;
}
//if inventory button pressed
if (inviconbtn)
{
hinventorycanvas.enabled = true;
//ShowInventory();
}
}
// got to look at GM to figure out the types for the inventory
/*void ShowInventory()
{
string labeltxt = "";
string labelimg = "";
int counter = 0;
for (int i = 0; i < invcapacity; i++)
{
counter = i + 1;
//update icon and text
labeltxt = "Text" + counter;
labelimg = "Image" + counter;
Text text = GameObject.Find(labeltxt).GetComponent("Text") as Text;
text.text = inventory[i, 1] + " x " + inventory[i, 2]; // Need to fill out the inventory
Image image = GameObject.Find(labelimg).GetComponent("Image") as Image;
Sprite invicon = Resources.Load<Sprite>(inventory[i, 3]);
image.sprite = invicon;
}
}*/
}
}