Skip to content

Commit 166a446

Browse files
committed
cleanup
1 parent 14f2875 commit 166a446

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Assets/UXF/Examples/3_MultiScene_FootballAndRT/Scripts/Example_ReactionTask.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public void StartReactionTaskTrial(Trial trial)
2222

2323
public void EndReactionTaskTrial(Trial trial)
2424
{
25+
// sometimes we quit the application mid session, and that ends the current trial. If that is the case, we don't need to do anything here.
26+
if (Session.instance.isEnding) return;
27+
2528
// show some feedback
2629
string outcomeText = (string) trial.result["outcome"];
2730
float rt = (float) trial.result["reaction_time"];

Assets/UXF/Scripts/Session.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ public class Session : MonoBehaviour, ISettingsContainer, IDataAssociatable
115115
[Tooltip("Event(s) to trigger when the session has ended and all jobs have finished. It is safe to quit the application beyond this event")]
116116
public SessionEvent onSessionEnd = new SessionEvent();
117117

118+
/// <summary>
119+
/// Returns true when the session is in the process of ending. It is useful to query this in On Trial End events, since you may not need to perform some behaviour if the session is ending.
120+
/// </summary>
121+
/// <value></value>
122+
public bool isEnding { get; private set; } = false;
118123

119124
[SerializeField]
120125
private bool _hasInitialised = false;
@@ -600,6 +605,7 @@ public void End()
600605
{
601606
if (hasInitialised)
602607
{
608+
isEnding = true;
603609
if (InTrial)
604610
CurrentTrial.End();
605611
SaveResults();
@@ -618,6 +624,7 @@ public void End()
618624
_hasInitialised = false;
619625

620626
Debug.Log("Ended session.");
627+
isEnding = false;
621628
}
622629
}
623630

0 commit comments

Comments
 (0)