Tried to get it all in the title.
I’ve got a Item class.
public string name;
public Texture2D icon;
public bool droppable;
public Item(string _name, Texture2D _icon, bool _droppable)
{
name = _name;
icon = _icon;
droppable = _droppable;
}
And I’m simply trying to get a copy of the data when clicked to add into a inventory (list of ‘items’) however I keep seeing ‘Missing item’ or ‘None (Item)’ in the inspector.
Which is kind of strange seeing as I’m looping through the list in my OnGUI function and it still displays the data I want…
This is my raycast to click on items
if (Physics.Raycast (ray, out hit)) {
if(Input.GetMouseButton(0))
{
if(hit.collider.tag == "Item")
{
Item _item = hit.collider.GetComponent<Item>();
inventory.Add (new Item(_item.name, _item.icon, false));
Destroy(hit.collider.gameObject);
}
}
}
Thanks!