I am working on a different inventory type system. What I would like it do here is be able to search the array, and if there is in fact a “Sphere” in the array, tell the user they have 1 or more Spheres. Not sure if it is possible, or maybe I should be using a list. Not sure. Any advice or tips??
here is the inventory script. I have other scripts to add items to the array already.
using UnityEngine;
using System.Collections;
public class Inventory : MonoBehaviour {
public GameObject[] items;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
void OnGUI()
{
//Insted of indexing of a specific, I want to check if any gameobject in items
//is equal to FindWithTag "Sphere". Is that possible?
if (items[0] == GameObject.FindWithTag("Sphere"))
{
GUI.Label(new Rect(100, 100, 100, 100), "You have a (or this many) sphere(s)");
}
}
}