Ejemplo n.º 1
0
        /// <summary>
        /// Updates references to Transform objects that we're interested in.
        /// </summary>
        private void UpdateTransformReferences()
        {
            Transform newParent;
            if (relativeTrn == null) {
                if (FlightGlobals.ActiveVessel == null) {
                    newParent = null;
                } else {
                    newParent = FlightGlobals.ActiveVessel.transform;
                }
            } else {
                newParent = relativeTrn;
            }
            TransformState.MoveToParent(destructionProxy.transform, newParent);
            TransformState.ResetTransformToIdentity(destructionProxy.transform);
            TransformState.ResetTransformToIdentity(transform);

            // For FlightCamera, the second transform is that for the FlightCamera itself.
            secondTrn = new TransformState(FlightCamera.fetch.transform);
            // ... and the transform parent is the "main camera pivot".
            firstTrn = new TransformState(secondTrn.Transform.parent);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Moves toMove, retaining the local position, scale, rotation.
 /// 
 /// This is in contrast to simply modifying Transform.parent, which modifies
 /// the local transformation state to retain the same world-space result.
 /// </summary>
 /// <param name="toMove">The Transform to reparent.</param>
 /// <param name="newParent">The new parent Transform.</param>
 public static void MoveToParent(Transform toMove, Transform newParent)
 {
     var state = new TransformState(toMove);
     toMove.parent = newParent;
     state.Revert();
 }