private static Bounds GetUnrotatedRendererBounds(GameObject target) { Transform oldParent = target.transform.parent; Quaternion oldRotation = target.transform.rotation; Transform[] children = null; if (oldParent) { children = DetachReattach.DetachChildren(oldParent.gameObject); } target.transform.rotation = Quaternion.identity; if (!target.GetComponent <BoxCollider>()) { } Bounds bounds = target.GetComponent <Renderer>().bounds; target.transform.rotation = oldRotation; if (oldParent) { DetachReattach.ReattachChildren(children, oldParent.gameObject); } return(bounds); }
public static void ReattachChildrenAndRestoreRotation(GameObject target, State state) { target.transform.rotation = state.rotation; if (state.parent) { DetachReattach.ReattachChildren(state.children, state.parent.gameObject); } }