private void CheckKeyPresses(CritterEditorInputManager critterEditorInputManager) {
        if (critterEditorInputManager.keyFDown) {  // pressing 'f' centers the camera on the currently selected segment, or entire critter is nothing selected
            critterEditorInputManager.critterConstructorCameraController.SetFocalPoint(selectedSegment);
            //critterEditorInputManager.critterConstructorCameraController.ReframeCamera();
        }
        if (critterEditorInputManager.keyQDown) {
            SetToolState(CurrentToolState.None);
        }
        if (critterEditorInputManager.keyWDown) {
            SetToolState(CurrentToolState.MoveAttachPoint);
        }
        if (critterEditorInputManager.keyRDown) {
            //Debug.Log("key r down SETTOOLSTATE");
            SetToolState(CurrentToolState.ScaleSegment);
        }
        if (critterEditorInputManager.keyAltDown) {  // pressing 'alt' enters camera mode  -- any clicks will control camera and nothing else
            altIsDown = true;
            //currentCameraState = CurrentCameraState.Static;  // alt is down -- but no mouse-click -- 
        }
        if (critterEditorInputManager.keyAltUp) {  // letting go of alt exits camera mode
            altIsDown = false;
        }
        if (critterEditorInputManager.mouseLeftClickDown) {  // left-clicked this frame
            mouseLeftIsDown = true;
        }
        if (critterEditorInputManager.mouseLeftClickUp) {  // released the left-click
            mouseLeftIsDown = false;
        }
        if (critterEditorInputManager.mouseMiddleClickDown) {  // Middle-clicked this frame
            mouseMiddleIsDown = true;
        }
        if (critterEditorInputManager.mouseMiddleClickUp) {  // released the Middle-click
            mouseMiddleIsDown = false;
        }
        if (critterEditorInputManager.mouseRightClickDown) {  // Right-clicked this frame
            mouseRightIsDown = true;

        }
        if (critterEditorInputManager.mouseRightClickUp) {  // released the Right-click
            mouseRightIsDown = false;
        }
    }
    private void UpdateCameraState(CritterEditorInputManager critterEditorInputManager) {
        // CAMERA:
        // Determine Camera Mode:
        if (altIsDown) {
            currentCameraState = CurrentCameraState.Static; // default
            if (mouseMiddleIsDown) {  // PAN
                currentCameraState = CurrentCameraState.Pan;
            }
            if (mouseLeftIsDown) {  // Rotate:
                currentCameraState = CurrentCameraState.Rotate;
            }
            if (mouseRightIsDown) {  // Zoom:
                currentCameraState = CurrentCameraState.Zoom;
            }
            critterEditorUI.buttonDisplayCameraMode.interactable = false;
            if (isSegmentHover) {                
                hoverSegment.GetComponent<MeshRenderer>().material.SetFloat("_DisplayTarget", 0f);  // turn on selected vis
            }
        }
        else {  // not in camera mode:
            currentCameraState = CurrentCameraState.Off;
            if (mouseMiddleIsDown) {  // middle w/e

            }
            if (mouseLeftIsDown) {  // Left-Click:
                // Check For Selecting
            }
            if (mouseRightIsDown) {  // Right-Click:

            }
            critterEditorUI.buttonDisplayCameraMode.interactable = true;
        }
        critterEditorInputManager.critterConstructorCameraController.UpdateCamera(this);  // pan, zoom, rotate, or do nothing
        UpdateGizmos();
    }
    public void UpdateStatesFromInput(CritterEditorInputManager critterEditorInputManager) {
        UpdateGravityStrength();
        //Debug.Log("UpdateStatesFromInput(CritterEditorInputManager critterEditorInputManager)");
        
        CheckKeyPresses(critterEditorInputManager);
        UpdateCameraState(critterEditorInputManager);

        // Check for updated States:
        if (currentCameraState == CurrentCameraState.Off) {  // if Not in CAMERA mode, then check for other stuff:

            // Check for commands from EditorUI buttons:
            if(changeStateFromEditorUI) {  // if a button has been pressed in the EditorUI GUI
                SetToolState(pendingToolStateFromEditorUI); // update Tool State
                changeStateFromEditorUI = false;  // reset trigger
            }

            // Check Right-click menu state:
            //======= If Right-click menu is on: ======================================================
            if (rightClickMenuOn) {
                // don't need to check for raycasts, just check if mouse is over a button
                if (critterEditorInputManager.mouseRightClickUp) {  // right click menu was exited this frame:
                    CommandRCMenuOff();                    
                }
            }
            else {   // right-click menu OFF
                // Check for Gizmos:
                //ShootGizmoRaycast();
                // Check for Segment:
                //ShootSegmentRaycast();
                if(mouseOverUI) {

                }
                else {
                    ShootEditorRaycasts();
                    UpdateHoverState();  // Using raycast information, determine the status of the hover state -- did mouse cursor enter, exit, or switch hover targets?

                    if (critterEditorInputManager.mouseRightClickDown) {  // right-clicked this frame
                                                                          // right click menu was entered this frame:
                        CommandRCMenuOn();
                    }

                    if (critterEditorInputManager.mouseLeftClickDown) {  // left-clicked this frame
                        if (isGizmoHover) {
                            CommandLeftClickGizmoDown();
                        }
                        else {
                            if (isSegmentHover) {  //if left-Click on a segment
                                CommandLeftClickSegment();
                            }
                            else {  // left-clicked on emptiness:
                                CommandLeftClickNone();
                            }
                        }
                    }
                    if (isGizmoEngaged) {
                        if (critterEditorInputManager.mouseLeftClickUp) {
                            CommandLeftClickGizmoUp();
                        }
                        else {
                            CommandGizmoOn();
                        }
                    }
                }                
            }            
        }
        else {
            //Debug.Log("Camera Mode ON");
        }
        // VVVVVVV The code below is duplicated within the Set Tool State() method -- look into consolidating and cleaning this up!!!
        if(currentToolState == CurrentToolState.None) {
            critterEditorUI.buttonDisplayView.interactable = false;
            critterEditorUI.textButtonView.fontStyle = FontStyle.Bold;
        }
        else {
            critterEditorUI.buttonDisplayView.interactable = true;
            critterEditorUI.textButtonView.fontStyle = FontStyle.Normal;
        }
        if (currentToolState == CurrentToolState.ScaleSegment) {
            critterEditorUI.buttonDisplayScale.interactable = false;
            critterEditorUI.textButtonScale.fontStyle = FontStyle.Bold;
        }
        else {
            critterEditorUI.buttonDisplayScale.interactable = true;
            critterEditorUI.textButtonScale.fontStyle = FontStyle.Normal;
        }
        if (currentToolState == CurrentToolState.MoveAttachPoint) {
            critterEditorUI.buttonDisplayMoveJoint.interactable = false;
            critterEditorUI.textButtonMove.fontStyle = FontStyle.Bold;
        }
        else {
            critterEditorUI.buttonDisplayMoveJoint.interactable = true;
            critterEditorUI.textButtonMove.fontStyle = FontStyle.Normal;
        }

        critterEditorUI.UpdateSelectedDisplayText(isSegmentSelected, selectedSegment, isGizmoEngaged, engagedGizmo, selectedSegmentGizmo);
        if(isPhysicsPreview) {
            critterEditorUI.UpdateSegmentSettingsPanel(isSegmentSelected, selectedSegment, false);
            critterEditorUI.UpdateNodeAddonsPanel(isSegmentSelected, selectedSegment, false);
        }
        else {
            if(isSegmentSelected) {
                critterEditorUI.UpdateSegmentSettingsPanel(isSegmentSelected, selectedSegment, true);
                critterEditorUI.UpdateNodeAddonsPanel(isSegmentSelected, selectedSegment, true);
            }
            else {
                critterEditorUI.UpdateSegmentSettingsPanel(isSegmentSelected, selectedSegment, false);
                critterEditorUI.UpdateNodeAddonsPanel(isSegmentSelected, selectedSegment, false);
            }
        }
        
    }