Skip to content

Commit 67b9c1e

Browse files
committed
Adding OnBlockBegin & OnBlockEnd UnityEvents
1 parent 4d64bcf commit 67b9c1e

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

Assets/UXF/Scripts/Etc/Events.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ public class SessionEvent : UnityEvent<Session>
1515

1616
}
1717

18+
/// <summary>
19+
/// Event containing a Block as a parameter
20+
/// </summary>
21+
[Serializable]
22+
public class BlockEvent : UnityEvent<Block>
23+
{
24+
25+
}
26+
1827
/// <summary>
1928
/// Event containing a Trial as a parameter
2029
/// </summary>

Assets/UXF/Scripts/Etc/Trial.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ public void Begin()
119119
Utilities.UXFDebugLogWarning("An item in the Tracked Objects field of the UXF session if empty (null)!");
120120
}
121121
}
122+
123+
if (this == block.firstTrial)
124+
{
125+
// call block on begin event
126+
}
127+
122128
session.onTrialBegin.Invoke(this);
123129
}
124130

@@ -137,6 +143,11 @@ public void End()
137143
}
138144

139145
session.onTrialEnd.Invoke(this);
146+
147+
if (this == block.lastTrial)
148+
{
149+
// call block on end event
150+
}
140151
}
141152

142153
public bool CheckDataTypeIsValid(string dataName, UXFDataType dataType)

Assets/UXF/Scripts/Session.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ public class Session : MonoBehaviour, IExperimentUnit, IDataAssociatable
9393
[Tooltip("Items in this event will be triggered when the session begins. Useful generating your trials & blocks, setting up the scene, and triggering the first trial.")]
9494
public SessionEvent onSessionBegin = new SessionEvent();
9595

96+
/// <summary>
97+
/// Event(s) to trigger when a block begins. Can pass the instance of the Block as a dynamic argument
98+
/// </summary>
99+
/// <returns></returns>
100+
[Tooltip("Items in this event will be triggered each time a block begins.")]
101+
public BlockEvent onBlockBegin = new BlockEvent();
102+
96103
/// <summary>
97104
/// Event(s) to trigger when a trial begins. Can pass the instance of the Trial as a dynamic argument
98105
/// </summary>
@@ -107,6 +114,13 @@ public class Session : MonoBehaviour, IExperimentUnit, IDataAssociatable
107114
[Tooltip("Items in this event will be triggered each time a trial ends. Useful for collecting results from the trial as well as showing feedback.")]
108115
public TrialEvent onTrialEnd = new TrialEvent();
109116

117+
/// <summary>
118+
/// Event(s) to trigger when a block ends. Can pass the instance of the Block as a dynamic argument
119+
/// </summary>
120+
/// <returns></returns>
121+
[Tooltip("Items in this event will be triggered each time a block ends.")]
122+
public BlockEvent onBlockEnd = new BlockEvent();
123+
110124
/// <summary>
111125
/// Event(s) to trigger just before the session has ended. If you wish to perform any summary statistics or write any final session data this is the time to do it. Do not use this event to quit the application.
112126
/// </summary>

0 commit comments

Comments
 (0)