/// <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); }
private void ReplaceProxy() { if (destructionProxy != null) { destructionProxy.onDestroy -= this.OnProxyDestroyed; } GameObject obj = new GameObject("KerbCam.CameraController DestructionProxy"); destructionProxy = obj.AddComponent <DestructionProxy>(); destructionProxy.onDestroy += OnProxyDestroyed; TransformState.MoveToParent(transform, destructionProxy.transform); }
private void ReacquireFlightCamera() { if (!isControlling) { return; } FlightCamera.fetch.DeactivateUpdate(); UpdateTransformReferences(); // Store the first and second transform states, for when we release the camera. firstTrn.Store(); secondTrn.Store(); // The CameraController becomes the parent transform for the camera transforms. TransformState.MoveToParent(firstTrn.Transform, transform); }