Skip to content

Commit d5f1d7c

Browse files
committed
Adding quick settings lock
1 parent 52e438e commit d5f1d7c

6 files changed

Lines changed: 102 additions & 13 deletions

File tree

Assets/Scenes/TrajectoryPlanner.unity

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,17 @@ MonoBehaviour:
222222
m_Script: {fileID: 11500000, guid: 2da0c512f12947e489f739169773d7ca, type: 3}
223223
m_Name:
224224
m_EditorClassIdentifier:
225+
--- !u!114 &121884410 stripped
226+
MonoBehaviour:
227+
m_CorrespondingSourceObject: {fileID: 6774864783474415589, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
228+
m_PrefabInstance: {fileID: 341190943874437988}
229+
m_PrefabAsset: {fileID: 0}
230+
m_GameObject: {fileID: 0}
231+
m_Enabled: 1
232+
m_EditorHideFlags: 0
233+
m_Script: {fileID: 11500000, guid: 75822e5514edb0d42b76f8c24264f0e2, type: 3}
234+
m_Name:
235+
m_EditorClassIdentifier:
225236
--- !u!114 &160775271 stripped
226237
MonoBehaviour:
227238
m_CorrespondingSourceObject: {fileID: 193214259762620640, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
@@ -3396,6 +3407,34 @@ PrefabInstance:
33963407
propertyPath: _accountsManager
33973408
value:
33983409
objectReference: {fileID: 809984607}
3410+
- target: {fileID: 4306952370464967406, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
3411+
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size
3412+
value: 1
3413+
objectReference: {fileID: 0}
3414+
- target: {fileID: 4306952370464967406, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
3415+
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Mode
3416+
value: 1
3417+
objectReference: {fileID: 0}
3418+
- target: {fileID: 4306952370464967406, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
3419+
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
3420+
value:
3421+
objectReference: {fileID: 121884410}
3422+
- target: {fileID: 4306952370464967406, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
3423+
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_CallState
3424+
value: 2
3425+
objectReference: {fileID: 0}
3426+
- target: {fileID: 4306952370464967406, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
3427+
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
3428+
value: InvokeLockEvent
3429+
objectReference: {fileID: 0}
3430+
- target: {fileID: 4306952370464967406, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
3431+
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
3432+
value: QuickSettingsLockBehavior, trajectoryplanner.ui
3433+
objectReference: {fileID: 0}
3434+
- target: {fileID: 4306952370464967406, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
3435+
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
3436+
value: UnityEngine.Object, UnityEngine
3437+
objectReference: {fileID: 0}
33993438
- target: {fileID: 4456086472949524093, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
34003439
propertyPath: m_AnchorMax.y
34013440
value: 1
@@ -3764,6 +3803,34 @@ PrefabInstance:
37643803
propertyPath: m_AnchoredPosition.y
37653804
value: 0
37663805
objectReference: {fileID: 0}
3806+
- target: {fileID: 6774864783474415589, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
3807+
propertyPath: LockEvent.m_PersistentCalls.m_Calls.Array.size
3808+
value: 1
3809+
objectReference: {fileID: 0}
3810+
- target: {fileID: 6774864783474415589, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
3811+
propertyPath: LockEvent.m_PersistentCalls.m_Calls.Array.data[0].m_Mode
3812+
value: 0
3813+
objectReference: {fileID: 0}
3814+
- target: {fileID: 6774864783474415589, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
3815+
propertyPath: LockEvent.m_PersistentCalls.m_Calls.Array.data[0].m_Target
3816+
value:
3817+
objectReference: {fileID: 2108153954}
3818+
- target: {fileID: 6774864783474415589, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
3819+
propertyPath: LockEvent.m_PersistentCalls.m_Calls.Array.data[0].m_CallState
3820+
value: 2
3821+
objectReference: {fileID: 0}
3822+
- target: {fileID: 6774864783474415589, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
3823+
propertyPath: LockEvent.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
3824+
value: LockActiveProbe
3825+
objectReference: {fileID: 0}
3826+
- target: {fileID: 6774864783474415589, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
3827+
propertyPath: LockEvent.m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
3828+
value: TrajectoryPlanner.TrajectoryPlannerManager, trajectoryplanner.core
3829+
objectReference: {fileID: 0}
3830+
- target: {fileID: 6774864783474415589, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
3831+
propertyPath: LockEvent.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
3832+
value: UnityEngine.Object, UnityEngine
3833+
objectReference: {fileID: 0}
37673834
- target: {fileID: 6785611152075342182, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
37683835
propertyPath: m_AnchorMax.y
37693836
value: 0
@@ -3952,6 +4019,10 @@ PrefabInstance:
39524019
propertyPath: m_AnchoredPosition.x
39534020
value: 311.77
39544021
objectReference: {fileID: 0}
4022+
- target: {fileID: 8017547552066817441, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
4023+
propertyPath: _lockBehavior
4024+
value:
4025+
objectReference: {fileID: 121884410}
39554026
- target: {fileID: 8017547552066817445, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
39564027
propertyPath: m_IsActive
39574028
value: 0

Assets/Scripts/TrajectoryPlanner/Probes/DefaultProbeController.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ private void CheckForSpeedKeys()
116116
keySlow = Input.GetKey(KeyCode.LeftControl);
117117
}
118118

119-
public bool MoveProbe_Keyboard()
119+
public void MoveProbe_Keyboard()
120120
{
121121
// drag movement takes precedence
122122
if (dragging || Locked)
123-
return false;
123+
return;
124124

125125
bool moved = false;
126126
bool keyHoldDelayPassed = (Time.realtimeSinceStartup - keyPressTime) > keyHoldDelay;
@@ -385,12 +385,6 @@ public bool MoveProbe_Keyboard()
385385
// Update all the UI panels
386386
ProbeManager.UpdateUI();
387387
FinishedMovingEvent.Invoke();
388-
389-
return true;
390-
}
391-
else
392-
{
393-
return false;
394388
}
395389
}
396390

@@ -506,7 +500,7 @@ private void CheckForPreviousDragClick()
506500
public void DragMovementDrag()
507501
{
508502
// Cancel movement if being controlled by EphysLink
509-
if (ProbeManager.IsEphysLinkControlled)
503+
if (ProbeManager.IsEphysLinkControlled || Locked)
510504
return;
511505

512506
CheckForSpeedKeys();

Assets/Scripts/TrajectoryPlanner/Probes/ProbeManager.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ public void SetColor(Color color)
178178
puiManager.UpdateColors();
179179
}
180180

181+
public void SetLock(bool locked)
182+
{
183+
_probeController.Locked = locked;
184+
}
185+
181186
public void DisableAllColliders()
182187
{
183188
foreach (var probeCollider in _probeColliders)
@@ -386,13 +391,13 @@ public void ChangeRecordingRegionSize(float newSize)
386391
/// Move the probe
387392
/// </summary>
388393
/// <returns>Whether or not the probe moved on this frame</returns>
389-
public bool MoveProbe()
394+
public void MoveProbe()
390395
{
391396
// Cancel movement if being controlled by EphysLink
392397
if (IsEphysLinkControlled)
393-
return false;
398+
return;
394399

395-
return ((DefaultProbeController)_probeController).MoveProbe_Keyboard();
400+
((DefaultProbeController)_probeController).MoveProbe_Keyboard();
396401
}
397402

398403
#region Text

Assets/Scripts/TrajectoryPlanner/TP_ProbeQuickSettings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class TP_ProbeQuickSettings : MonoBehaviour
2020
[FormerlySerializedAs("automaticMovementSpeedInputField")] [SerializeField] private TMP_InputField _automaticMovementSpeedInputField;
2121
[FormerlySerializedAs("automaticMovementControlPanelGameObject")] [SerializeField] private GameObject _automaticMovementControlPanelGameObject;
2222
[FormerlySerializedAs("automaticMovementGoButton")] [SerializeField] private Button _automaticMovementGoButton;
23+
[SerializeField] private QuickSettingsLockBehavior _lockBehavior;
2324

2425
private CommunicationManager _communicationManager;
2526
private TrajectoryPlannerManager _trajectoryPlannerManager;
@@ -73,6 +74,8 @@ public void SetActiveProbeManager()
7374
UpdateAutomaticControlPanel();
7475
});
7576

77+
_lockBehavior.SetLockState(ProbeManager.ActiveProbeManager.GetProbeController().Locked);
78+
7679
UpdateCoordinates();
7780
UpdateInteractable();
7881
UpdateAutomaticControlPanel();

Assets/Scripts/TrajectoryPlanner/TrajectoryPlannerManager.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,11 @@ public void ResetActiveProbe()
660660
ProbeManager.ActiveProbeManager.GetProbeController().ResetInsertion();
661661
}
662662

663+
public void LockActiveProbe(bool locked)
664+
{
665+
ProbeManager.ActiveProbeManager.SetLock(locked);
666+
}
667+
663668
#region Warping
664669

665670
public void WarpBrain()

Assets/Scripts/TrajectoryPlanner/UI/QuickSettingsLockBehavior.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,21 @@ public class QuickSettingsLockBehavior : MonoBehaviour
1616
public void InvokeLockEvent()
1717
{
1818
_locked = !_locked;
19+
UpdateSprite();
20+
LockEvent.Invoke(_locked);
21+
}
22+
23+
public void SetLockState(bool state)
24+
{
25+
_locked = state;
26+
UpdateSprite();
27+
}
28+
29+
private void UpdateSprite()
30+
{
1931
if (_locked)
2032
_sprite.sprite = _lockSprite;
2133
else
2234
_sprite.sprite = _unlockSprite;
23-
LockEvent.Invoke(_locked);
2435
}
2536
}

0 commit comments

Comments
 (0)