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 OnProxyDestroyed(DestructionProxy p) { if (object.ReferenceEquals(p, destructionProxy)) { ReplaceProxy(); // The destruction of the proxy probably indicates that the // relative object has been destroyed. Reparent to default. relativeTrn = null; UpdateTransformReferences(); } }