diff --git a/Assets/Prefabs/UI/SettingsMenu/Menus/EphysLinkMenu.prefab b/Assets/Prefabs/UI/SettingsMenu/Menus/EphysLinkMenu.prefab index 748806e1..f683b830 100644 --- a/Assets/Prefabs/UI/SettingsMenu/Menus/EphysLinkMenu.prefab +++ b/Assets/Prefabs/UI/SettingsMenu/Menus/EphysLinkMenu.prefab @@ -2565,7 +2565,7 @@ MonoBehaviour: m_PressedTrigger: Pressed m_SelectedTrigger: Selected m_DisabledTrigger: Disabled - m_Interactable: 1 + m_Interactable: 0 m_TargetGraphic: {fileID: 6487466997665187127} toggleTransition: 1 graphic: {fileID: 2477337667047670143} diff --git a/Assets/Scripts/Pinpoint/UI/EphysCopilot/InsertionSelectionPanelHandler.cs b/Assets/Scripts/Pinpoint/UI/EphysCopilot/InsertionSelectionPanelHandler.cs index a17906ee..14631bdf 100644 --- a/Assets/Scripts/Pinpoint/UI/EphysCopilot/InsertionSelectionPanelHandler.cs +++ b/Assets/Scripts/Pinpoint/UI/EphysCopilot/InsertionSelectionPanelHandler.cs @@ -246,13 +246,21 @@ public void UpdateTargetInsertionOptions() .Select(probeManager => (probeManager.OverrideName ?? probeManager.name) + ": " + SurfaceCoordinateToString(probeManager.GetSurfaceCoordinateT())).ToList()); + // Return early if no manipulator ID + if (ProbeManager.ManipulatorBehaviorController.ManipulatorID == null) return; + // Restore selection (if possible) var selectedProbeManager = ManipulatorIDToSelectedTargetProbeManager.GetValueOrDefault( ProbeManager.ManipulatorBehaviorController.ManipulatorID, null); - _targetInsertionDropdown.SetValueWithoutNotify( - _targetProbeManagerOptions.ToList() - .IndexOf(selectedProbeManager) + 1 - ); + if (selectedProbeManager == null) + // Select none if no previous selection. + _targetInsertionDropdown.SetValueWithoutNotify(0); + else + _targetInsertionDropdown.SetValueWithoutNotify( + _targetProbeManagerOptions.ToList() + .IndexOf(selectedProbeManager) + 1 + ); + // Color dropdown to match probe color if (!selectedProbeManager) return; diff --git a/Assets/Scripts/Pinpoint/UI/EphysLinkSettings/EphysLinkSettings.cs b/Assets/Scripts/Pinpoint/UI/EphysLinkSettings/EphysLinkSettings.cs index 8efdc807..ca48284b 100644 --- a/Assets/Scripts/Pinpoint/UI/EphysLinkSettings/EphysLinkSettings.cs +++ b/Assets/Scripts/Pinpoint/UI/EphysLinkSettings/EphysLinkSettings.cs @@ -85,15 +85,11 @@ private void UpdateConnectionPanel() private void UpdateManipulatorPanels() { // Default Copilot to be disabled unless the right manipulator type is found - _copilotToggle.interactable = false; if (CommunicationManager.Instance.IsConnected) { CommunicationManager.Instance.GetManipulators((availableIDs, numAxes, _) => { - // Enable Copilot button if using Sensapex or New Scale - _copilotToggle.interactable = numAxes > 0; - // Keep track of handled manipulator panels var handledManipulatorIds = new HashSet(); @@ -232,6 +228,9 @@ public void ToggleCopilotPanel(bool isEnabled) public void InvokeShouldUpdateProbesListEvent() { ShouldUpdateProbesListEvent.Invoke(); + + // Enable/Disable Copilot toggle based on if there are any probes that can be controlled by it. + _copilotToggle.interactable = LinkedProbes.Count > 0; } #endregion