diff --git a/.gitignore b/.gitignore index 0e73a570..a9b689d1 100644 --- a/.gitignore +++ b/.gitignore @@ -66,4 +66,6 @@ $RECYCLE.BIN/ .idea/* example_output/* -Assets/MyAWSCredentials.asset* \ No newline at end of file +Assets/MyAWSCredentials.asset* + +UserSettings/ diff --git a/Assets/UXF/Examples/3_MultiScene_FootballAndRT/Scripts/Example_MultiSceneExperimentGenerator.cs b/Assets/UXF/Examples/3_MultiScene_FootballAndRT/Scripts/Example_MultiSceneExperimentGenerator.cs index ca2d64e6..193e7833 100644 --- a/Assets/UXF/Examples/3_MultiScene_FootballAndRT/Scripts/Example_MultiSceneExperimentGenerator.cs +++ b/Assets/UXF/Examples/3_MultiScene_FootballAndRT/Scripts/Example_MultiSceneExperimentGenerator.cs @@ -77,11 +77,19 @@ void SceneSpecificSetup(Trial trial) // there are lots of ways to do this, but this works fine here if (trial.block.number == 1) { +#if UNITY_6000 + FindFirstObjectByType().StartShootingTaskTrial(trial); +#else FindObjectOfType().StartShootingTaskTrial(trial); +#endif } else if (trial.block.number == 2) { +#if UNITY_6000 + FindFirstObjectByType().StartReactionTaskTrial(trial); +#else FindObjectOfType().StartReactionTaskTrial(trial); +#endif } } @@ -94,11 +102,19 @@ public void CleanupTrial(Trial trial) // there are lots of ways to do this, but this works fine here if (trial.block.number == 1) { +#if UNITY_6000 + FindFirstObjectByType().EndShootingTaskTrial(trial); +#else FindObjectOfType().EndShootingTaskTrial(trial); +#endif } else if (trial.block.number == 2) { +#if UNITY_6000 + FindFirstObjectByType().EndReactionTaskTrial(trial); +#else FindObjectOfType().EndReactionTaskTrial(trial); +#endif } } @@ -157,4 +173,4 @@ void AddScenesToBuildIndex() # endif } -} \ No newline at end of file +} diff --git a/Assets/UXF/Examples/3_MultiScene_FootballAndRT/Scripts/Example_Shooter.cs b/Assets/UXF/Examples/3_MultiScene_FootballAndRT/Scripts/Example_Shooter.cs index c182e3c2..aaa2fa1e 100644 --- a/Assets/UXF/Examples/3_MultiScene_FootballAndRT/Scripts/Example_Shooter.cs +++ b/Assets/UXF/Examples/3_MultiScene_FootballAndRT/Scripts/Example_Shooter.cs @@ -51,7 +51,11 @@ void Update() // launch when clicked if (Input.GetMouseButtonDown(0)) { +#if UNITY_6000 + ball.linearVelocity = launchVelocity; +#else ball.velocity = launchVelocity; +#endif canShoot = false; // only have a certain time to score, or its classified as a miss! @@ -82,4 +86,4 @@ public void Timeout() } } -} \ No newline at end of file +} diff --git a/Assets/UXF/Scripts/DataHandling/WebAWSDynamoDB.cs b/Assets/UXF/Scripts/DataHandling/WebAWSDynamoDB.cs index dfa1fdfc..a3c8156e 100644 --- a/Assets/UXF/Scripts/DataHandling/WebAWSDynamoDB.cs +++ b/Assets/UXF/Scripts/DataHandling/WebAWSDynamoDB.cs @@ -466,7 +466,9 @@ public override bool IsIncompatibleWith(UnityEditor.BuildTargetGroup buildTarget { case UnityEditor.BuildTargetGroup.Android: case UnityEditor.BuildTargetGroup.iOS: +#if !UNITY_2022_2_OR_NEWER case UnityEditor.BuildTargetGroup.Lumin: +#endif case UnityEditor.BuildTargetGroup.PS4: case UnityEditor.BuildTargetGroup.Switch: case UnityEditor.BuildTargetGroup.tvOS: diff --git a/Assets/UXF/Scripts/Etc/Editor/UXFSessionDisplay.cs b/Assets/UXF/Scripts/Etc/Editor/UXFSessionDisplay.cs index 67dd92c8..46086aec 100644 --- a/Assets/UXF/Scripts/Etc/Editor/UXFSessionDisplay.cs +++ b/Assets/UXF/Scripts/Etc/Editor/UXFSessionDisplay.cs @@ -41,7 +41,11 @@ static void OnPlayModeStateChanged(PlayModeStateChange state) static void FetchReferences() { +#if UNITY_6000 + session = FindFirstObjectByType(); +#else session = FindObjectOfType(); +#endif if (!session) { settingsDict = null; @@ -206,4 +210,4 @@ static string Truncate(string value, int maxChars) } } -} \ No newline at end of file +} diff --git a/Assets/UXF/Scripts/Etc/Editor/UXFWizard.cs b/Assets/UXF/Scripts/Etc/Editor/UXFWizard.cs index 19cf2692..7837081e 100644 --- a/Assets/UXF/Scripts/Etc/Editor/UXFWizard.cs +++ b/Assets/UXF/Scripts/Etc/Editor/UXFWizard.cs @@ -1,8 +1,7 @@ -using System.Collections; -using System.IO; -using System.Collections.Generic; +using System.IO; using UnityEngine; using UnityEditor; +using UnityEditor.Build; namespace UXF.EditorUtils { @@ -137,7 +136,13 @@ public void OnGUI() GUILayout.Label("Compatibility", EditorStyles.boldLabel); - bool compatible = PlayerSettings.GetApiCompatibilityLevel(BuildTargetGroup.Standalone) == targetApiLevel; +#if UNITY_6000 + var standalone = NamedBuildTarget.Android; +#else + var standalone = BuildTargetGroup.Standalone; +#endif + + bool compatible = PlayerSettings.GetApiCompatibilityLevel(standalone) == targetApiLevel; if (compatible) { @@ -148,7 +153,7 @@ public void OnGUI() 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); if (GUILayout.Button("Fix")) { - PlayerSettings.SetApiCompatibilityLevel(BuildTargetGroup.Standalone, targetApiLevel); + PlayerSettings.SetApiCompatibilityLevel(standalone, targetApiLevel); } } diff --git a/Assets/UXF/Scripts/EventSystemFallback.cs b/Assets/UXF/Scripts/EventSystemFallback.cs index d093d129..c4f8e859 100644 --- a/Assets/UXF/Scripts/EventSystemFallback.cs +++ b/Assets/UXF/Scripts/EventSystemFallback.cs @@ -28,11 +28,15 @@ void Start() void CreateEventSystem() { +#if UNITY_6000 + if (FindFirstObjectByType() == null) +#else if (FindObjectOfType() == null) +#endif { var newEventSystem = Instantiate(eventSystemPrefab); newEventSystem.name = "EventSystem"; } } } -} \ No newline at end of file +} diff --git a/Assets/UXF/Tests/Editor/TestFileIOManager.cs b/Assets/UXF/Tests/Editor/TestFileIOManager.cs index 4ca4dc95..1463c0ab 100644 --- a/Assets/UXF/Tests/Editor/TestFileIOManager.cs +++ b/Assets/UXF/Tests/Editor/TestFileIOManager.cs @@ -1,37 +1,31 @@ using UnityEngine; -using UnityEditor; -using UnityEngine.Events; -using UnityEngine.TestTools; using System.Collections.Generic; using NUnit.Framework; -using System.Collections; using System.IO; namespace UXF.Tests { - public class TestFileSaver { - string experiment = "fileSaver_test"; string ppid = "test_ppid"; int sessionNum = 1; - FileSaver fileSaver; + FileSaver fileSaver; [SetUp] public void SetUp() { - var gameObject = new GameObject(); - fileSaver = gameObject.AddComponent(); - fileSaver.verboseDebug = true; + var gameObject = new GameObject(); + fileSaver = gameObject.AddComponent(); + fileSaver.verboseDebug = true; } - [TearDown] - public void TearDown() - { - GameObject.DestroyImmediate(fileSaver.gameObject); - } + [TearDown] + public void TearDown() + { + GameObject.DestroyImmediate(fileSaver.gameObject); + } [Test] @@ -41,32 +35,34 @@ public void WriteManyFiles() fileSaver.SetUp(); // generate a large dictionary - var dict = new Dictionary(); + var dict = new Dictionary(); var largeArray = new string[100]; string largeString = new string('*', 50000); - // write lots and lots of JSON files - int n = 100; + // write lots and lots of JSON files + int n = 100; string[] fpaths = new string[n]; - for (int i = 0; i < n; i++) - { - string fileName = string.Format("{0}", i); - Debug.LogFormat("Queueing {0}", fileName); - string fpath = fileSaver.HandleText(largeString, experiment, ppid, sessionNum, fileName, UXFDataType.OtherSessionData); + for (int i = 0; i < n; i++) + { + string fileName = string.Format("{0}", i); + Debug.LogFormat("Queueing {0}", fileName); + string fpath = fileSaver.HandleText(largeString, experiment, ppid, sessionNum, fileName, + UXFDataType.OtherSessionData); fpaths[i] = fpath; - } + } Debug.Log("###########################################"); Debug.Log("############## CLEANING UP ################"); Debug.Log("###########################################"); fileSaver.CleanUp(); - Assert.Throws(() => { + Assert.Throws(() => + { fileSaver.HandleText(largeString, experiment, ppid, sessionNum, "0", UXFDataType.OtherSessionData); }); - // cleanup files + // cleanup files foreach (var fpath in fpaths) { System.IO.File.Delete(Path.Combine(fileSaver.StoragePath, fpath)); @@ -80,12 +76,10 @@ public void EarlyExit() fileSaver.StoragePath = "example_output"; fileSaver.SetUp(); fileSaver.CleanUp(); - - Assert.Throws( - () => { - fileSaver.ManageInWorker(() => Debug.Log("Code enqueued after FileSaver ended")); - } - ); + + Assert.Throws( + () => { fileSaver.ManageInWorker(() => Debug.Log("Code enqueued after FileSaver ended")); } + ); fileSaver.SetUp(); fileSaver.ManageInWorker(() => Debug.Log("Code enqueued after FileSaver re-opened")); @@ -95,10 +89,18 @@ public void EarlyExit() [Test] public void AbsolutePath() { - fileSaver.StoragePath = "C:/example_output"; + if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.Windows) + { + fileSaver.StoragePath = "C:/example_output"; + } + else + { + fileSaver.StoragePath = "/tmp/example_output"; + } fileSaver.SetUp(); - - string outString = fileSaver.HandleText("abc", experiment, ppid, sessionNum, "test", UXFDataType.OtherSessionData); + + string outString = + fileSaver.HandleText("abc", experiment, ppid, sessionNum, "test", UXFDataType.OtherSessionData); Assert.AreEqual(outString, @"fileSaver_test/test_ppid/S001/other/test.txt"); @@ -115,18 +117,18 @@ public void PersistentDataPath() string dataOutput = "abc"; fileSaver.HandleText(dataOutput, experiment, ppid, sessionNum, "test", UXFDataType.OtherSessionData); fileSaver.CleanUp(); - string outFile = Path.Combine(Application.persistentDataPath, @"fileSaver_test/test_ppid/S001/other/test.txt"); + string outFile = Path.Combine(Application.persistentDataPath, + @"fileSaver_test/test_ppid/S001/other/test.txt"); string readData = File.ReadAllText(outFile); Assert.AreEqual(dataOutput, readData); - + if (File.Exists(outFile)) File.Delete(outFile); } [Test] public void FileSaverRelPath() { - Assert.AreEqual( FileSaver.GetRelativePath("C:\\base", "C:\\base\\123"), "123" @@ -139,15 +141,13 @@ public void FileSaverRelPath() Assert.AreEqual( FileSaver.GetRelativePath("base/", "base\\123"), - "123" + SystemInfo.operatingSystemFamily == OperatingSystemFamily.Windows ? "123" : "../123" ); Assert.AreEqual( FileSaver.GetRelativePath("C:/base/", "C:/base\\123"), - "123" + SystemInfo.operatingSystemFamily == OperatingSystemFamily.Windows ? "123" : "../123" ); } - } - -} \ No newline at end of file +} diff --git a/Assets/UXF/Tests/Editor/TestJSON.cs b/Assets/UXF/Tests/Editor/TestJSON.cs index 36b3cff4..1fcd829e 100644 --- a/Assets/UXF/Tests/Editor/TestJSON.cs +++ b/Assets/UXF/Tests/Editor/TestJSON.cs @@ -1,28 +1,23 @@ using UnityEngine; -using UnityEditor; -using UnityEngine.TestTools; using NUnit.Framework; -using System.Collections; using System.Collections.Generic; -using System.IO; namespace UXF.Tests { - public class TestJSON - { + public class TestJSON + { + Dictionary dict = new Dictionary() + { + {"string", "aaa"}, + {"bool", true}, + {"int", 3}, + {"float", 3.14f}, + {"list", new List() {1, 2, 3, 4}}, + {"array", new object[] {1, 2, 3, 4}}, + {"object", new Dictionary() {{"a", 1}, {"b", "abc"}}} + }; - Dictionary dict = new Dictionary() - { - {"string", "aaa"}, - {"bool", true}, - {"int", 3}, - {"float", 3.14f}, - {"list", new List(){1, 2, 3, 4}}, - {"array", new object[]{1, 2, 3, 4}}, - {"object", new Dictionary(){{"a", 1}, {"b", "abc"}}} - }; - - const string jsonString = @"{ + const string jsonString = @"{ ""string"": ""aaa"", ""bool"": true, ""int"": 3, @@ -46,22 +41,22 @@ public class TestJSON }"; - [Test] - public void JSONIndentation() - { - string outString = MiniJSON.Json.Serialize(dict); - Assert.AreEqual(jsonString, outString); - } + [Test] + public void JSONIndentation() + { + string outString = MiniJSON.Json.Serialize(dict); + Assert.AreEqual(jsonString, outString.Replace("\r", "")); + } - [Test] - public void VectorSerialize() - { + [Test] + public void VectorSerialize() + { var vectorDict = new Dictionary { - { "vector3", new Vector3(1, 2, 3) }, - { "vector2", new Vector2(1, 2) } + {"vector3", new Vector3(1, 2, 3)}, + {"vector2", new Vector2(1, 2)} }; - + string vectorString = @"{ ""vector3"": { ""x"": 1, @@ -73,11 +68,9 @@ public void VectorSerialize() ""y"": 2 } }"; - - string outString = MiniJSON.Json.Serialize(vectorDict); - Assert.AreEqual(vectorString, outString); - } - - } + string outString = MiniJSON.Json.Serialize(vectorDict); + Assert.AreEqual(vectorString, outString.Replace("\r", "")); + } + } } \ No newline at end of file diff --git a/Assets/UXF/VERSION.txt b/Assets/UXF/VERSION.txt index 6550da69..59aa62c1 100644 --- a/Assets/UXF/VERSION.txt +++ b/Assets/UXF/VERSION.txt @@ -1 +1 @@ -2.4.3 \ No newline at end of file +2.4.5 diff --git a/Assets/WebGLTemplates/UXF WebGL 2019/index.html b/Assets/WebGLTemplates/UXF WebGL 2019/index.html index 9a29c011..0c2bd138 100644 --- a/Assets/WebGLTemplates/UXF WebGL 2019/index.html +++ b/Assets/WebGLTemplates/UXF WebGL 2019/index.html @@ -59,7 +59,7 @@

%UNITY_WEB_NAME%

Experiment developed with - UXF + UXF