public void FindNextBox() { box next = null; Debug.Log(boxes.Count); if (boxes.Count > 0) { foreach (GameObject g in boxes) { if ((next == null || g.GetComponent <box>().GetTimeUnformatted() < next.GetTimeUnformatted()) && g.GetComponent <box>().GetTimeUnformatted() != 0) { next = g.GetComponent <box>(); } } if (next != null) { Debug.Log(next.GetTimeUnformatted() + " < " + this.GetTimeUnformatted()); if (next.GetTimeUnformatted() < this.GetTimeUnformatted()) { currentExport = next.gameObject; et.setTruck(next.GetComponent <SpriteRenderer>().color, currentExport.GetComponent <box>().ToString()); } } } }