Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Inventory : MonoBehaviour
- {
- public List<GameObject> itemsGOInInventory = new List<GameObject>();
- public void AddItem(GameObject itemToBeAdded)
- {
- itemsGOInInventory.Add(itemToBeAdded);
- Destroy(itemToBeAdded);
- }
- public void FindItem(string name)
- {
- foreach (GameObject item in itemsGOInInventory)
- {
- if (item.GetComponent<Item>().itemName == "pistol")
- {
- Instantiate(item.GetComponent<Item>().itemObject, this.transform);
- }
- }
- }
- }
- public class InventoryItem
- {
- string name;
- string description;
- string spritePath;
- // other variables
- }
- public class InventoryItemView : MonoBehaviour
- {
- public InventoryItem item;
- // ...
- }
- public class Inventory : MonoBehaviour
- {
- public List<InventoryItem> itemsGOInInventory = new List<InventoryItem>();
- public void AddItem(GameObject itemToBeAdded)
- {
- itemsGOInInventory.Add(itemToBeAdded.GetComponent<InventoryItemView>().item);
- Destroy(itemToBeAdded);
- }
- //...
- }
- itemToBeAdded.SetActive(false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement