コード例 #1
0
        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);
        }
コード例 #2
0
 public static void ReattachChildrenAndRestoreRotation(GameObject target, State state)
 {
     target.transform.rotation = state.rotation;
     if (state.parent)
     {
         DetachReattach.ReattachChildren(state.children, state.parent.gameObject);
     }
 }
コード例 #3
0
        public static State DetachChildrenAndZeroRotation(GameObject target)
        {
            State state = new State();

            state.target   = target;
            state.rotation = target.transform.rotation;
            state.parent   = target.transform.parent;
            state.children = null;
            if (state.parent)
            {
                state.children = DetachReattach.DetachChildren(state.parent.gameObject);
            }
            target.transform.rotation = Quaternion.identity;
            return(state);
        }