Skip to content

Commit 6f43243

Browse files
authored
Merge pull request #177 from govertbuijs/master
Fixes #171, #172 and #173
2 parents eb80232 + ca0b042 commit 6f43243

File tree

111 files changed

+124
-10001
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+124
-10001
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,6 @@ $RECYCLE.BIN/
6666
.idea/*
6767
example_output/*
6868

69-
Assets/MyAWSCredentials.asset*
69+
Assets/MyAWSCredentials.asset*
70+
71+
UserSettings/

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,19 @@ void SceneSpecificSetup(Trial trial)
7777
// there are lots of ways to do this, but this works fine here
7878
if (trial.block.number == 1)
7979
{
80+
#if UNITY_6000
81+
FindFirstObjectByType<Example_ShootingTask>().StartShootingTaskTrial(trial);
82+
#else
8083
FindObjectOfType<Example_ShootingTask>().StartShootingTaskTrial(trial);
84+
#endif
8185
}
8286
else if (trial.block.number == 2)
8387
{
88+
#if UNITY_6000
89+
FindFirstObjectByType<Example_ReactionTask>().StartReactionTaskTrial(trial);
90+
#else
8491
FindObjectOfType<Example_ReactionTask>().StartReactionTaskTrial(trial);
92+
#endif
8593
}
8694
}
8795

@@ -94,11 +102,19 @@ public void CleanupTrial(Trial trial)
94102
// there are lots of ways to do this, but this works fine here
95103
if (trial.block.number == 1)
96104
{
105+
#if UNITY_6000
106+
FindFirstObjectByType<Example_ShootingTask>().EndShootingTaskTrial(trial);
107+
#else
97108
FindObjectOfType<Example_ShootingTask>().EndShootingTaskTrial(trial);
109+
#endif
98110
}
99111
else if (trial.block.number == 2)
100112
{
113+
#if UNITY_6000
114+
FindFirstObjectByType<Example_ReactionTask>().EndReactionTaskTrial(trial);
115+
#else
101116
FindObjectOfType<Example_ReactionTask>().EndReactionTaskTrial(trial);
117+
#endif
102118
}
103119
}
104120

@@ -157,4 +173,4 @@ void AddScenesToBuildIndex()
157173
# endif
158174

159175
}
160-
}
176+
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ void Update()
5151
// launch when clicked
5252
if (Input.GetMouseButtonDown(0))
5353
{
54+
#if UNITY_6000
55+
ball.linearVelocity = launchVelocity;
56+
#else
5457
ball.velocity = launchVelocity;
58+
#endif
5559
canShoot = false;
5660

5761
// only have a certain time to score, or its classified as a miss!
@@ -82,4 +86,4 @@ public void Timeout()
8286
}
8387

8488
}
85-
}
89+
}

Assets/UXF/Scripts/DataHandling/WebAWSDynamoDB.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,9 @@ public override bool IsIncompatibleWith(UnityEditor.BuildTargetGroup buildTarget
466466
{
467467
case UnityEditor.BuildTargetGroup.Android:
468468
case UnityEditor.BuildTargetGroup.iOS:
469+
#if !UNITY_2022_2_OR_NEWER
469470
case UnityEditor.BuildTargetGroup.Lumin:
471+
#endif
470472
case UnityEditor.BuildTargetGroup.PS4:
471473
case UnityEditor.BuildTargetGroup.Switch:
472474
case UnityEditor.BuildTargetGroup.tvOS:

Assets/UXF/Scripts/Etc/Editor/UXFSessionDisplay.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ static void OnPlayModeStateChanged(PlayModeStateChange state)
4141

4242
static void FetchReferences()
4343
{
44+
#if UNITY_6000
45+
session = FindFirstObjectByType<Session>();
46+
#else
4447
session = FindObjectOfType<Session>();
48+
#endif
4549
if (!session)
4650
{
4751
settingsDict = null;
@@ -206,4 +210,4 @@ static string Truncate(string value, int maxChars)
206210
}
207211
}
208212

209-
}
213+
}

Assets/UXF/Scripts/Etc/Editor/UXFWizard.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
using System.Collections;
2-
using System.IO;
3-
using System.Collections.Generic;
1+
using System.IO;
42
using UnityEngine;
53
using UnityEditor;
4+
using UnityEditor.Build;
65

76
namespace UXF.EditorUtils
87
{
@@ -137,7 +136,13 @@ public void OnGUI()
137136

138137
GUILayout.Label("Compatibility", EditorStyles.boldLabel);
139138

140-
bool compatible = PlayerSettings.GetApiCompatibilityLevel(BuildTargetGroup.Standalone) == targetApiLevel;
139+
#if UNITY_6000
140+
var standalone = NamedBuildTarget.Android;
141+
#else
142+
var standalone = BuildTargetGroup.Standalone;
143+
#endif
144+
145+
bool compatible = PlayerSettings.GetApiCompatibilityLevel(standalone) == targetApiLevel;
141146

142147
if (compatible)
143148
{
@@ -148,7 +153,7 @@ public void OnGUI()
148153
EditorGUILayout.HelpBox("API Compatibility Level should be set to .NET 2.0 (Older versions of Unity) or .NET 4.x (Unity 2018.3+), expect errors on building", MessageType.Warning);
149154
if (GUILayout.Button("Fix"))
150155
{
151-
PlayerSettings.SetApiCompatibilityLevel(BuildTargetGroup.Standalone, targetApiLevel);
156+
PlayerSettings.SetApiCompatibilityLevel(standalone, targetApiLevel);
152157
}
153158
}
154159

Assets/UXF/Scripts/EventSystemFallback.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,15 @@ void Start()
2828

2929
void CreateEventSystem()
3030
{
31+
#if UNITY_6000
32+
if (FindFirstObjectByType<EventSystem>() == null)
33+
#else
3134
if (FindObjectOfType<EventSystem>() == null)
35+
#endif
3236
{
3337
var newEventSystem = Instantiate(eventSystemPrefab);
3438
newEventSystem.name = "EventSystem";
3539
}
3640
}
3741
}
38-
}
42+
}
Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,31 @@
11
using UnityEngine;
2-
using UnityEditor;
3-
using UnityEngine.Events;
4-
using UnityEngine.TestTools;
52
using System.Collections.Generic;
63
using NUnit.Framework;
7-
using System.Collections;
84
using System.IO;
95

106
namespace UXF.Tests
117
{
12-
138
public class TestFileSaver
149
{
15-
1610
string experiment = "fileSaver_test";
1711
string ppid = "test_ppid";
1812
int sessionNum = 1;
19-
FileSaver fileSaver;
13+
FileSaver fileSaver;
2014

2115
[SetUp]
2216
public void SetUp()
2317
{
24-
var gameObject = new GameObject();
25-
fileSaver = gameObject.AddComponent<FileSaver>();
26-
fileSaver.verboseDebug = true;
18+
var gameObject = new GameObject();
19+
fileSaver = gameObject.AddComponent<FileSaver>();
20+
fileSaver.verboseDebug = true;
2721
}
2822

2923

30-
[TearDown]
31-
public void TearDown()
32-
{
33-
GameObject.DestroyImmediate(fileSaver.gameObject);
34-
}
24+
[TearDown]
25+
public void TearDown()
26+
{
27+
GameObject.DestroyImmediate(fileSaver.gameObject);
28+
}
3529

3630

3731
[Test]
@@ -41,32 +35,34 @@ public void WriteManyFiles()
4135
fileSaver.SetUp();
4236

4337
// generate a large dictionary
44-
var dict = new Dictionary<string, object>();
38+
var dict = new Dictionary<string, object>();
4539

4640
var largeArray = new string[100];
4741
string largeString = new string('*', 50000);
4842

49-
// write lots and lots of JSON files
50-
int n = 100;
43+
// write lots and lots of JSON files
44+
int n = 100;
5145
string[] fpaths = new string[n];
52-
for (int i = 0; i < n; i++)
53-
{
54-
string fileName = string.Format("{0}", i);
55-
Debug.LogFormat("Queueing {0}", fileName);
56-
string fpath = fileSaver.HandleText(largeString, experiment, ppid, sessionNum, fileName, UXFDataType.OtherSessionData);
46+
for (int i = 0; i < n; i++)
47+
{
48+
string fileName = string.Format("{0}", i);
49+
Debug.LogFormat("Queueing {0}", fileName);
50+
string fpath = fileSaver.HandleText(largeString, experiment, ppid, sessionNum, fileName,
51+
UXFDataType.OtherSessionData);
5752
fpaths[i] = fpath;
58-
}
53+
}
5954

6055
Debug.Log("###########################################");
6156
Debug.Log("############## CLEANING UP ################");
6257
Debug.Log("###########################################");
6358
fileSaver.CleanUp();
6459

65-
Assert.Throws<System.InvalidOperationException>(() => {
60+
Assert.Throws<System.InvalidOperationException>(() =>
61+
{
6662
fileSaver.HandleText(largeString, experiment, ppid, sessionNum, "0", UXFDataType.OtherSessionData);
6763
});
6864

69-
// cleanup files
65+
// cleanup files
7066
foreach (var fpath in fpaths)
7167
{
7268
System.IO.File.Delete(Path.Combine(fileSaver.StoragePath, fpath));
@@ -80,12 +76,10 @@ public void EarlyExit()
8076
fileSaver.StoragePath = "example_output";
8177
fileSaver.SetUp();
8278
fileSaver.CleanUp();
83-
84-
Assert.Throws<System.InvalidOperationException>(
85-
() => {
86-
fileSaver.ManageInWorker(() => Debug.Log("Code enqueued after FileSaver ended"));
87-
}
88-
);
79+
80+
Assert.Throws<System.InvalidOperationException>(
81+
() => { fileSaver.ManageInWorker(() => Debug.Log("Code enqueued after FileSaver ended")); }
82+
);
8983

9084
fileSaver.SetUp();
9185
fileSaver.ManageInWorker(() => Debug.Log("Code enqueued after FileSaver re-opened"));
@@ -95,10 +89,18 @@ public void EarlyExit()
9589
[Test]
9690
public void AbsolutePath()
9791
{
98-
fileSaver.StoragePath = "C:/example_output";
92+
if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.Windows)
93+
{
94+
fileSaver.StoragePath = "C:/example_output";
95+
}
96+
else
97+
{
98+
fileSaver.StoragePath = "/tmp/example_output";
99+
}
99100
fileSaver.SetUp();
100-
101-
string outString = fileSaver.HandleText("abc", experiment, ppid, sessionNum, "test", UXFDataType.OtherSessionData);
101+
102+
string outString =
103+
fileSaver.HandleText("abc", experiment, ppid, sessionNum, "test", UXFDataType.OtherSessionData);
102104

103105
Assert.AreEqual(outString, @"fileSaver_test/test_ppid/S001/other/test.txt");
104106

@@ -115,18 +117,18 @@ public void PersistentDataPath()
115117
string dataOutput = "abc";
116118
fileSaver.HandleText(dataOutput, experiment, ppid, sessionNum, "test", UXFDataType.OtherSessionData);
117119
fileSaver.CleanUp();
118-
string outFile = Path.Combine(Application.persistentDataPath, @"fileSaver_test/test_ppid/S001/other/test.txt");
120+
string outFile = Path.Combine(Application.persistentDataPath,
121+
@"fileSaver_test/test_ppid/S001/other/test.txt");
119122

120123
string readData = File.ReadAllText(outFile);
121124
Assert.AreEqual(dataOutput, readData);
122-
125+
123126
if (File.Exists(outFile)) File.Delete(outFile);
124127
}
125128

126129
[Test]
127130
public void FileSaverRelPath()
128131
{
129-
130132
Assert.AreEqual(
131133
FileSaver.GetRelativePath("C:\\base", "C:\\base\\123"),
132134
"123"
@@ -139,15 +141,13 @@ public void FileSaverRelPath()
139141

140142
Assert.AreEqual(
141143
FileSaver.GetRelativePath("base/", "base\\123"),
142-
"123"
144+
SystemInfo.operatingSystemFamily == OperatingSystemFamily.Windows ? "123" : "../123"
143145
);
144146

145147
Assert.AreEqual(
146148
FileSaver.GetRelativePath("C:/base/", "C:/base\\123"),
147-
"123"
149+
SystemInfo.operatingSystemFamily == OperatingSystemFamily.Windows ? "123" : "../123"
148150
);
149151
}
150-
151152
}
152-
153-
}
153+
}

0 commit comments

Comments
 (0)