public void ReplaceBoxes(GameObject replacement) { int childCount = transform.childCount; for (int i = 0; i < childCount; i++) { Transform current = transform.GetChild(i); BoxPile boxPile = current.GetComponent <BoxPile>(); if (boxPile != null) { boxPile.replacement = replacement; boxPile.normalizeScale = normalizeScale; boxPile.ReplaceBoxes(); } else { string objectName = current.gameObject.name; Debug.Log("Could not replace " + objectName + ". This object is missing a <Box Pile> component."); } } }
private void OnEnable() { component = (BoxPile)target; }