CameraFocusChanger.CameraFocusChanger.Update C# (CSharp) Method

Update() private method

private Update ( ) : void
return void
        void Update()
        {
            // check if we are trying to change the focus
            GameObject obj = EventSystem.current.currentSelectedGameObject;
            bool inputFieldIsFocused = InputLockManager.IsAllLocked(ControlTypes.KEYBOARDINPUT) || (obj != null && obj.GetComponent<InputField>() != null && obj.GetComponent<InputField>().isFocused);
            if (!inputFieldIsFocused && Input.GetKeyDown(actionKey))
            {
                DebugPrint("updating camera focus");

                if ((Time.time - startFocusTime) < 0.25f)
                {
                    hasReachedTarget = true;
                }
                else
                {
                    // find a part under the mouse, if there is one, set it as the camera's point of focus
                    // otherwise, revert to the center of mass
                    Transform raycastTransform = GetTransform();
                    if (raycastTransform != null)
                    {
                        FocusOn(raycastTransform);
                    }
                    else if (targetTransform != null)
                    {
                        ResetFocus();
                    }
                    else
                    {
                        hasReachedTarget = true;
                    }
                }
            }

            if (!inputFieldIsFocused && Input.GetKeyDown(KeyCode.Y))
            {
                DebugPrint(string.Format("target: {0}", targetTransform));
                DebugPrint(string.Format("vessel: {0}", FlightGlobals.ActiveVessel.GetWorldPos3D()));
                DebugPrint(string.Format("camera: {0}", flightCamera.transform.parent.position));
            }

            UpdateFocus();
        }