void CenterOnChildren(ColliderAgregator obj) { List <Vector3> childrenPlaces = new List <Vector3>(); foreach (BoxCollider2D child in obj.childColiders) { if (child.gameObject.GetInstanceID() != obj.gameObject.GetInstanceID()) { childrenPlaces.Add(child.gameObject.transform.position); } } obj.transform.position = (GetAvarageFromList(childrenPlaces)); for (int i = 0; i < childrenPlaces.Count; i++) { obj.childColiders[i + 1].transform.position = childrenPlaces[i]; } }
void GetChildrensBox(ColliderAgregator t) { t.childColiders = t.gameObject.transform.GetComponentsInChildren <BoxCollider2D>(); }