Exemplo n.º 1
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();
        }
Exemplo n.º 2
0
        private void ReleaseFlightCamera()
        {
            if (!isControlling)
            {
                return;
            }
            isControlling = false;

            // Restore parentage of first and second transforms. This mutates their state
            // to retain their current position, so revert must be *after* this.
            firstTrn.Transform.parent = (FlightGlobals.ActiveVessel == null ?
                                         null : FlightGlobals.ActiveVessel.transform);
            secondTrn.Transform.parent = firstTrn.Transform; // Probably hasn't changed anyway.

            firstTrn.Revert();
            secondTrn.Revert();

            FlightCamera.fetch.ActivateUpdate();
        }