Skip to content

Commit af5a354

Browse files
committed
Fixed example
1 parent b92c5af commit af5a354

File tree

3 files changed

+93
-386
lines changed

3 files changed

+93
-386
lines changed

Assets/ExpMngr/Example.unity

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,26 @@ Prefab:
222222
m_Modification:
223223
m_TransformParent: {fileID: 0}
224224
m_Modifications:
225+
- target: {fileID: 114734091223803794, guid: 628989ad7601cc449aa1a5ad29d1d483,
226+
type: 2}
227+
propertyPath: _customHeaders.Array.size
228+
value: 1
229+
objectReference: {fileID: 0}
230+
- target: {fileID: 114734091223803794, guid: 628989ad7601cc449aa1a5ad29d1d483,
231+
type: 2}
232+
propertyPath: _trackedObjects.Array.size
233+
value: 1
234+
objectReference: {fileID: 0}
235+
- target: {fileID: 114734091223803794, guid: 628989ad7601cc449aa1a5ad29d1d483,
236+
type: 2}
237+
propertyPath: onTrialBegin.m_PersistentCalls.m_Calls.Array.size
238+
value: 1
239+
objectReference: {fileID: 0}
240+
- target: {fileID: 114734091223803794, guid: 628989ad7601cc449aa1a5ad29d1d483,
241+
type: 2}
242+
propertyPath: onSessionStart.m_PersistentCalls.m_Calls.Array.size
243+
value: 1
244+
objectReference: {fileID: 0}
225245
- target: {fileID: 4522850482104986, guid: 628989ad7601cc449aa1a5ad29d1d483, type: 2}
226246
propertyPath: m_LocalPosition.x
227247
value: 0
@@ -262,17 +282,72 @@ Prefab:
262282
- target: {fileID: 224130118367839794, guid: 628989ad7601cc449aa1a5ad29d1d483,
263283
type: 2}
264284
propertyPath: m_AnchorMax.x
265-
value: 0
285+
value: 1
266286
objectReference: {fileID: 0}
267287
- target: {fileID: 224130118367839794, guid: 628989ad7601cc449aa1a5ad29d1d483,
268288
type: 2}
269289
propertyPath: m_AnchorMax.y
270-
value: 0
290+
value: 1
271291
objectReference: {fileID: 0}
272292
- target: {fileID: 224546371281550106, guid: 628989ad7601cc449aa1a5ad29d1d483,
273293
type: 2}
274294
propertyPath: m_SizeDelta.y
275-
value: 5
295+
value: 0
296+
objectReference: {fileID: 0}
297+
- target: {fileID: 114734091223803794, guid: 628989ad7601cc449aa1a5ad29d1d483,
298+
type: 2}
299+
propertyPath: onSessionStart.m_PersistentCalls.m_Calls.Array.data[0].m_Mode
300+
value: 0
301+
objectReference: {fileID: 0}
302+
- target: {fileID: 114734091223803794, guid: 628989ad7601cc449aa1a5ad29d1d483,
303+
type: 2}
304+
propertyPath: onSessionStart.m_PersistentCalls.m_Calls.Array.data[0].m_CallState
305+
value: 2
306+
objectReference: {fileID: 0}
307+
- target: {fileID: 114734091223803794, guid: 628989ad7601cc449aa1a5ad29d1d483,
308+
type: 2}
309+
propertyPath: onSessionStart.m_PersistentCalls.m_Calls.Array.data[0].m_Target
310+
value:
311+
objectReference: {fileID: 42531503}
312+
- target: {fileID: 114734091223803794, guid: 628989ad7601cc449aa1a5ad29d1d483,
313+
type: 2}
314+
propertyPath: onSessionStart.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
315+
value: GenerateAndRunExperiment
316+
objectReference: {fileID: 0}
317+
- target: {fileID: 114734091223803794, guid: 628989ad7601cc449aa1a5ad29d1d483,
318+
type: 2}
319+
propertyPath: onSessionStart.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
320+
value: UnityEngine.Object, UnityEngine
321+
objectReference: {fileID: 0}
322+
- target: {fileID: 114734091223803794, guid: 628989ad7601cc449aa1a5ad29d1d483,
323+
type: 2}
324+
propertyPath: _customHeaders.Array.data[0]
325+
value: some_variable
326+
objectReference: {fileID: 0}
327+
- target: {fileID: 114734091223803794, guid: 628989ad7601cc449aa1a5ad29d1d483,
328+
type: 2}
329+
propertyPath: onTrialBegin.m_PersistentCalls.m_Calls.Array.data[0].m_Mode
330+
value: 1
331+
objectReference: {fileID: 0}
332+
- target: {fileID: 114734091223803794, guid: 628989ad7601cc449aa1a5ad29d1d483,
333+
type: 2}
334+
propertyPath: onTrialBegin.m_PersistentCalls.m_Calls.Array.data[0].m_CallState
335+
value: 2
336+
objectReference: {fileID: 0}
337+
- target: {fileID: 114734091223803794, guid: 628989ad7601cc449aa1a5ad29d1d483,
338+
type: 2}
339+
propertyPath: onTrialBegin.m_PersistentCalls.m_Calls.Array.data[0].m_Target
340+
value:
341+
objectReference: {fileID: 42531503}
342+
- target: {fileID: 114734091223803794, guid: 628989ad7601cc449aa1a5ad29d1d483,
343+
type: 2}
344+
propertyPath: onTrialBegin.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
345+
value: RunTrial
346+
objectReference: {fileID: 0}
347+
- target: {fileID: 114734091223803794, guid: 628989ad7601cc449aa1a5ad29d1d483,
348+
type: 2}
349+
propertyPath: onTrialBegin.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
350+
value: UnityEngine.Object, UnityEngine
276351
objectReference: {fileID: 0}
277352
m_RemovedComponents: []
278353
m_ParentPrefab: {fileID: 100100000, guid: 628989ad7601cc449aa1a5ad29d1d483, type: 2}

Assets/ExpMngr/ExampleScript.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ public class ExampleScript : MonoBehaviour {
1313
float startNextTime;
1414

1515

16+
void Start()
17+
{
18+
// disable this behavior so the Update() function doesnt run.
19+
enabled = false;
20+
}
21+
1622
public void GenerateAndRunExperiment(ExpMngr.ExperimentSession expSession) {
1723
exp = expSession;
1824
/// This function can be called using the ExperimentSession inspector OnSessionStart() event, or otherwise
@@ -48,6 +54,9 @@ public void GenerateAndRunExperiment(ExpMngr.ExperimentSession expSession) {
4854
// here we set a setting for the 2nd trial of the main block as an example.
4955
exp.GetBlock(2).GetRelativeTrial(2).settings["size"] = 10;
5056

57+
// setting this script to enabled allows the MonoBehaviour scripts to run e.g. Update()
58+
enabled = true;
59+
5160
// begin first trial
5261
exp.BeginNextTrial();
5362
}
@@ -58,10 +67,11 @@ void Update()
5867
if (Time.time > startNextTime && exp.inTrial)
5968
{
6069
Debug.Log("Ending trial");
70+
exp.currentTrial.End();
71+
6172
if (exp.currentTrial == exp.lastTrial)
6273
{
6374
// end, then quit
64-
exp.currentTrial.End();
6575
#if UNITY_EDITOR
6676
UnityEditor.EditorApplication.isPlaying = false;
6777
#elif UNITY_WEBPLAYER
@@ -72,14 +82,16 @@ void Update()
7282
}
7383
else
7484
{
75-
// end trial
76-
exp.currentTrial.End();
85+
// start next trial
86+
exp.BeginNextTrial();
7787
}
7888
}
7989
}
8090

8191
public void RunTrial()
8292
{
93+
94+
// we call this function via the event "On Trial Begin", which is called when the trial starts
8395
Debug.Log("Running trial!");
8496

8597
// we can access our settings to (e.g.) modify our scene

0 commit comments

Comments
 (0)