public void GetLateOrders() { orders = new List <OrderData>(GetComponentsInChildren <OrderData>()); foreach (OrderData w in orders) { string id = w.ID.text; Debug.Log("id:" + id); restAPI.GetOrder(id.Substring(3)); if (restAPI.IsCurrentOrderLate()) { //Debug.Log(w.GetComponentInParent<Material>().name); Debug.Log(w.GetComponentInParent <Transform>().gameObject.name); } } }