Question by
CreationAl3xStudio · Aug 14, 2020 at 02:54 PM ·
2d2d gameinventory system
I am getting an error while running my inventory script
This is my script
using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Reflection; using UnityEngine; using UnityEngine.UI;
public class GameManager : MonoBehaviour { public static GameManager instance;//MARKER SINGLETON PATTERN public bool isPaused;
public List<Item> items = new List<Item>();
public List<int> itemNumbers = new List<int>();
public GameObject[] slots;
private void Awake()
{
if (instance == null)
{
instance = this;
}
else
{
if(instance != this)
{
Destroy(gameObject);
}
}
DontDestroyOnLoad(gameObject);
}
private void Displayitems()
{
for (int i = 0; i < items.Count; i++)
{ //UPDATE slots Item Image
slots[i].transform.GetChild(0).GetComponent<Image>().color = new Color(1, 1, 1, 1);
slots[i].transform.GetChild(0).GetComponent<Image>().sprite = items[i].itemSprite;
//UPDATEE slots Count Text
slots[i].transform.GetChild(1).GetComponent<Text>().color = new Color(1, 1, 1, 1);
slots[i].transform.GetChild(1).GetComponent<Text>().text = itemNumbers[i].ToString();
//UPDATE CLOSE/THROW button
slots[i].transform.GetChild(2).gameObject.SetActive(true);
}
}
} and this is the error i get: Item' does not contain a definition for 'itemSprite' and no accessible extension method 'itemSprite' accepting a first argument of type 'Item' could be found (are you missing a using directive or an assembly reference?)
Comment