com.wallstop-studios.unity-helpers 2.0.0-rc49 → 2.0.0-rc51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Runtime/Core/Extension/UnityExtensions.cs +8 -0
- package/Runtime/Core/Helper/SceneHelper.cs +216 -0
- package/Runtime/Core/Helper/SceneHelper.cs.meta +3 -0
- package/Runtime/Core/Helper/UnityMainThreadDispatcher.cs +32 -0
- package/Runtime/Core/Helper/UnityMainThreadDispatcher.cs.meta +3 -0
- package/Runtime/Core/Random/AbstractRandom.cs +27 -4
- package/Runtime/Core/Serialization/JsonConverters/ColorConverter.cs +88 -0
- package/Runtime/Core/Serialization/JsonConverters/ColorConverter.cs.meta +3 -0
- package/Runtime/Core/Serialization/JsonConverters/GameObjectConverter.cs +37 -0
- package/Runtime/Core/Serialization/JsonConverters/GameObjectConverter.cs.meta +3 -0
- package/Runtime/Core/Serialization/JsonConverters/Matrix4x4Converter.cs +218 -0
- package/Runtime/Core/Serialization/JsonConverters/Matrix4x4Converter.cs.meta +3 -0
- package/Runtime/Core/Serialization/JsonConverters/Vector2Converter.cs +2 -2
- package/Runtime/Core/Serialization/JsonConverters/Vector3Converter.cs +3 -3
- package/Runtime/Core/Serialization/JsonConverters/Vector4Converter.cs +88 -0
- package/Runtime/Core/Serialization/JsonConverters/Vector4Converter.cs.meta +3 -0
- package/Runtime/Core/Serialization/Serializer.cs +8 -0
- package/Runtime/Utils/DeferredDisposalResult.cs +19 -0
- package/Runtime/Utils/DeferredDisposalResult.cs.meta +3 -0
- package/Tests/Runtime/Helper/SceneHelperTests.cs +92 -0
- package/Tests/Runtime/Helper/SceneHelperTests.cs.meta +3 -0
- package/Tests/Runtime/Scenes/Test1.unity +723 -0
- package/Tests/Runtime/Scenes/Test1.unity.meta +7 -0
- package/Tests/Runtime/Scenes/Test2.unity +723 -0
- package/Tests/Runtime/Scenes/Test2.unity.meta +7 -0
- package/Tests/Runtime/Scenes.meta +3 -0
- package/Tests/Runtime/Serialization/JsonSerializationTest.cs +64 -1
- package/package.json +1 -1
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
using System.Runtime.Serialization;
|
|
7
7
|
using System.Text.Json.Serialization;
|
|
8
8
|
using Core.Extension;
|
|
9
|
+
using Core.Helper;
|
|
9
10
|
using Core.Random;
|
|
10
11
|
using Core.Serialization;
|
|
11
12
|
using NUnit.Framework;
|
|
13
|
+
using UnityEngine;
|
|
12
14
|
|
|
13
15
|
[DataContract]
|
|
14
16
|
public sealed class TestDataObject
|
|
@@ -26,8 +28,69 @@
|
|
|
26
28
|
public List<Type> TypeProperties { get; set; } = new();
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
public class JsonSerializationTest
|
|
31
|
+
public sealed class JsonSerializationTest
|
|
30
32
|
{
|
|
33
|
+
[Test]
|
|
34
|
+
public void UnityEngineObjectSerializationWorks()
|
|
35
|
+
{
|
|
36
|
+
GameObject testGo = new("Test GameObject", typeof(SpriteRenderer));
|
|
37
|
+
string json = testGo.ToJson();
|
|
38
|
+
Assert.IsFalse(string.IsNullOrWhiteSpace(json), json);
|
|
39
|
+
Assert.AreNotEqual("{}", json);
|
|
40
|
+
Assert.IsTrue(json.Contains("name = Test GameObject"), json);
|
|
41
|
+
Assert.IsTrue(json.Contains("type = UnityEngine.GameObject"), json);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
[Test]
|
|
45
|
+
public void NullGameObjectSerializationWorks()
|
|
46
|
+
{
|
|
47
|
+
GameObject testGo = null;
|
|
48
|
+
string json = testGo.ToJson();
|
|
49
|
+
Assert.AreEqual("null", json);
|
|
50
|
+
|
|
51
|
+
testGo = new GameObject();
|
|
52
|
+
testGo.Destroy();
|
|
53
|
+
Assert.IsFalse(string.IsNullOrWhiteSpace(json), json);
|
|
54
|
+
Assert.AreEqual("null", json);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
[Test]
|
|
58
|
+
public void TransformSerializationWorks()
|
|
59
|
+
{
|
|
60
|
+
GameObject testGo = new("Test GameObject", typeof(SpriteRenderer));
|
|
61
|
+
Transform transform = testGo.transform;
|
|
62
|
+
string json = transform.ToJson();
|
|
63
|
+
Assert.AreEqual("[]", json);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
[Test]
|
|
67
|
+
public void ColorSerializationWorks()
|
|
68
|
+
{
|
|
69
|
+
Color color = new(0.5f, 0.5f, 0.5f, 0.5f);
|
|
70
|
+
string json = color.ToJson();
|
|
71
|
+
Color deserialized = Serializer.JsonDeserialize<Color>(json);
|
|
72
|
+
Assert.AreEqual(color, deserialized);
|
|
73
|
+
|
|
74
|
+
color = new Color(0.7f, 0.1f, 0.3f);
|
|
75
|
+
json = color.ToJson();
|
|
76
|
+
deserialized = Serializer.JsonDeserialize<Color>(json);
|
|
77
|
+
Assert.AreEqual(color, deserialized);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
[Test]
|
|
81
|
+
public void Vector4SerializationWorks()
|
|
82
|
+
{
|
|
83
|
+
Vector4 vector = new(0.5f, 0.5f, 0.5f, 0.5f);
|
|
84
|
+
string json = vector.ToJson();
|
|
85
|
+
Vector4 deserialized = Serializer.JsonDeserialize<Vector4>(json);
|
|
86
|
+
Assert.AreEqual(vector, deserialized);
|
|
87
|
+
|
|
88
|
+
vector = new Vector4(0.7f, 0.1f, 0.3f);
|
|
89
|
+
json = vector.ToJson();
|
|
90
|
+
deserialized = Serializer.JsonDeserialize<Vector4>(json);
|
|
91
|
+
Assert.AreEqual(vector, deserialized);
|
|
92
|
+
}
|
|
93
|
+
|
|
31
94
|
[Test]
|
|
32
95
|
public void SerializationWorks()
|
|
33
96
|
{
|