上传YomovSDK
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
#region License
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2020 Wanzyee Studio
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using Newtonsoft.Json.UnityConverters.Helpers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Newtonsoft.Json.UnityConverters.Math
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom Newtonsoft.Json converter <see cref="JsonConverter"/> for the Unity byte based Color type <see cref="Color32"/>.
|
||||
/// </summary>
|
||||
public class Color32Converter : PartialConverter<Color32>
|
||||
{
|
||||
protected override void ReadValue(ref Color32 value, string name, JsonReader reader, JsonSerializer serializer)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case nameof(value.r):
|
||||
value.r = reader.ReadAsInt8() ?? 0;
|
||||
break;
|
||||
case nameof(value.g):
|
||||
value.g = reader.ReadAsInt8() ?? 0;
|
||||
break;
|
||||
case nameof(value.b):
|
||||
value.b = reader.ReadAsInt8() ?? 0;
|
||||
break;
|
||||
case nameof(value.a):
|
||||
value.a = reader.ReadAsInt8() ?? 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void WriteJsonProperties(JsonWriter writer, Color32 value, JsonSerializer serializer)
|
||||
{
|
||||
writer.WritePropertyName(nameof(value.r));
|
||||
writer.WriteValue(value.r);
|
||||
writer.WritePropertyName(nameof(value.g));
|
||||
writer.WriteValue(value.g);
|
||||
writer.WritePropertyName(nameof(value.b));
|
||||
writer.WriteValue(value.b);
|
||||
writer.WritePropertyName(nameof(value.a));
|
||||
writer.WriteValue(value.a);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc4991667e8a84f4dba7eadfc16fd5a9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
#region License
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2020 Wanzyee Studio
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using Newtonsoft.Json.UnityConverters.Helpers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Newtonsoft.Json.UnityConverters.Math
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom Newtonsoft.Json converter <see cref="JsonConverter"/> for the Unity Color type <see cref="Color"/>.
|
||||
/// </summary>
|
||||
public class ColorConverter : PartialConverter<Color>
|
||||
{
|
||||
protected override void ReadValue(ref Color value, string name, JsonReader reader, JsonSerializer serializer)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case nameof(value.r):
|
||||
value.r = reader.ReadAsFloat() ?? 0f;
|
||||
break;
|
||||
case nameof(value.g):
|
||||
value.g = reader.ReadAsFloat() ?? 0f;
|
||||
break;
|
||||
case nameof(value.b):
|
||||
value.b = reader.ReadAsFloat() ?? 0f;
|
||||
break;
|
||||
case nameof(value.a):
|
||||
value.a = reader.ReadAsFloat() ?? 0f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void WriteJsonProperties(JsonWriter writer, Color value, JsonSerializer serializer)
|
||||
{
|
||||
writer.WritePropertyName(nameof(value.r));
|
||||
writer.WriteValue(value.r);
|
||||
writer.WritePropertyName(nameof(value.g));
|
||||
writer.WriteValue(value.g);
|
||||
writer.WritePropertyName(nameof(value.b));
|
||||
writer.WriteValue(value.b);
|
||||
writer.WritePropertyName(nameof(value.a));
|
||||
writer.WriteValue(value.a);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21096ef1f0a311e44ae8cf99f1add03b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,79 @@
|
||||
#region License
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2020 Wanzyee Studio
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json.UnityConverters.Helpers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Newtonsoft.Json.UnityConverters.Math
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom Newtonsoft.Json converter <see cref="JsonConverter"/> for the Unity Matrix4x4 type <see cref="Matrix4x4"/>.
|
||||
/// </summary>
|
||||
public class Matrix4x4Converter : PartialConverter<Matrix4x4>
|
||||
{
|
||||
// https://github.com/Unity-Technologies/UnityCsReference/blob/2019.2/Runtime/Export/Math/Matrix4x4.cs#L21-L29
|
||||
private static readonly string[] _names = GetMemberNames();
|
||||
private static readonly Dictionary<string, int> _namesToIndex = GetNamesToIndex(_names);
|
||||
|
||||
/// <summary>
|
||||
/// Get the property names include from <c>m00</c> to <c>m33</c>.
|
||||
/// </summary>
|
||||
/// <returns>The property names.</returns>
|
||||
private static string[] GetMemberNames()
|
||||
{
|
||||
string[] indexes = new[] { "0", "1", "2", "3" };
|
||||
return indexes.SelectMany((row) => indexes.Select((column) => "m" + column + row)).ToArray();
|
||||
}
|
||||
|
||||
// Reusing the same strings here instead of creating new ones. Tiny bit lower memory footprint
|
||||
private static Dictionary<string, int> GetNamesToIndex(string[] names)
|
||||
{
|
||||
var dict = new Dictionary<string, int>();
|
||||
for (int i = 0; i < names.Length; i++)
|
||||
{
|
||||
dict[names[i]] = i;
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
||||
protected override void ReadValue(ref Matrix4x4 value, string name, JsonReader reader, JsonSerializer serializer)
|
||||
{
|
||||
if (_namesToIndex.TryGetValue(name, out var index))
|
||||
{
|
||||
value[index] = reader.ReadAsFloat() ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void WriteJsonProperties(JsonWriter writer, Matrix4x4 value, JsonSerializer serializer)
|
||||
{
|
||||
for (int i = 0; i < _names.Length; i++)
|
||||
{
|
||||
writer.WritePropertyName(_names[i]);
|
||||
writer.WriteValue(value[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5145ef279cfb6f459ce307dfafd796a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
#region License
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2020 Wanzyee Studio
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using Newtonsoft.Json.UnityConverters.Helpers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Newtonsoft.Json.UnityConverters.Math
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom Newtonsoft.Json converter <see cref="JsonConverter"/> for the Unity Quaternion type <see cref="Quaternion"/>.
|
||||
/// </summary>
|
||||
public class QuaternionConverter : PartialConverter<Quaternion>
|
||||
{
|
||||
protected override void ReadValue(ref Quaternion value, string name, JsonReader reader, JsonSerializer serializer)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case nameof(value.x):
|
||||
value.x = reader.ReadAsFloat() ?? 0f;
|
||||
break;
|
||||
case nameof(value.y):
|
||||
value.y = reader.ReadAsFloat() ?? 0f;
|
||||
break;
|
||||
case nameof(value.z):
|
||||
value.z = reader.ReadAsFloat() ?? 0f;
|
||||
break;
|
||||
case nameof(value.w):
|
||||
value.w = reader.ReadAsFloat() ?? 0f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void WriteJsonProperties(JsonWriter writer, Quaternion value, JsonSerializer serializer)
|
||||
{
|
||||
writer.WritePropertyName(nameof(value.x));
|
||||
writer.WriteValue(value.x);
|
||||
writer.WritePropertyName(nameof(value.y));
|
||||
writer.WriteValue(value.y);
|
||||
writer.WritePropertyName(nameof(value.z));
|
||||
writer.WriteValue(value.z);
|
||||
writer.WritePropertyName(nameof(value.w));
|
||||
writer.WriteValue(value.w);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 915d1dc587bb37f49b42d57c1b4e2688
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,69 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Newtonsoft.Json.UnityConverters.Helpers;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Newtonsoft.Json.UnityConverters.Math
|
||||
{
|
||||
public class SphericalHarmonicsL2Converter : PartialConverter<SphericalHarmonicsL2>
|
||||
{
|
||||
// Magic numbers taken from /Runtime/Export/Math/SphericalHarmonicsL2.bindings.cs
|
||||
// inside Unitys open source repo
|
||||
// https://github.com/Unity-Technologies/UnityCsReference/blob/2019.2/Runtime/Export/Math/SphericalHarmonicsL2.bindings.cs#L59
|
||||
private const int COEFFICIENT_COUNT = 9;
|
||||
private const int ARRAY_SIZE = 3 * COEFFICIENT_COUNT;
|
||||
private static readonly (string name, int rgb, int coefficient)[] _indices = GetMemberNames();
|
||||
private static readonly Dictionary<string, (int color, int coefficient)> _nameToIndex = GetNamesToIndexDictionary(_indices);
|
||||
|
||||
private static (string name, int rgb, int coefficient)[] GetMemberNames()
|
||||
{
|
||||
var array = new (string name, int rgb, int coefficient)[ARRAY_SIZE];
|
||||
|
||||
for (int i = 0; i < COEFFICIENT_COUNT; i++)
|
||||
{
|
||||
array[i] = ('r' + i.ToString(), 0, i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < COEFFICIENT_COUNT; i++)
|
||||
{
|
||||
array[COEFFICIENT_COUNT + i] = ('g' + i.ToString(), 1, i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < COEFFICIENT_COUNT; i++)
|
||||
{
|
||||
array[COEFFICIENT_COUNT + COEFFICIENT_COUNT + i] = ('b' + i.ToString(), 2, i);
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
// Reusing the same strings here instead of creating new ones. Tiny bit lower memory footprint
|
||||
private static Dictionary<string, (int color, int coefficient)> GetNamesToIndexDictionary((string name, int rgb, int coefficient)[] indices)
|
||||
{
|
||||
var dict = new Dictionary<string, (int color, int coefficient)>();
|
||||
for (int i = 0; i < indices.Length; i++)
|
||||
{
|
||||
(string name, int rgb, int coefficient) = indices[i];
|
||||
dict[name] = (rgb, coefficient);
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
||||
protected override void ReadValue(ref SphericalHarmonicsL2 value, string name, JsonReader reader, JsonSerializer serializer)
|
||||
{
|
||||
if (_nameToIndex.TryGetValue(name, out var index))
|
||||
{
|
||||
value[index.color, index.coefficient] = reader.ReadAsFloat() ?? 0f;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void WriteJsonProperties(JsonWriter writer, SphericalHarmonicsL2 value, JsonSerializer serializer)
|
||||
{
|
||||
foreach (var (name, rgb, coefficient) in _indices)
|
||||
{
|
||||
writer.WritePropertyName(name);
|
||||
writer.WriteValue(value[rgb, coefficient]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 168d3269f6c4db14d8755f2c26b6f767
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,56 @@
|
||||
#region License
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2020 Wanzyee Studio
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using Newtonsoft.Json.UnityConverters.Helpers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Newtonsoft.Json.UnityConverters.Math
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom Newtonsoft.Json converter <see cref="JsonConverter"/> for the Unity Vector2 type <see cref="Vector2"/>.
|
||||
/// </summary>
|
||||
public class Vector2Converter : PartialConverter<Vector2>
|
||||
{
|
||||
protected override void ReadValue(ref Vector2 value, string name, JsonReader reader, JsonSerializer serializer)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case nameof(value.x):
|
||||
value.x = reader.ReadAsFloat() ?? 0f;
|
||||
break;
|
||||
case nameof(value.y):
|
||||
value.y = reader.ReadAsFloat() ?? 0f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void WriteJsonProperties(JsonWriter writer, Vector2 value, JsonSerializer serializer)
|
||||
{
|
||||
writer.WritePropertyName(nameof(value.x));
|
||||
writer.WriteValue(value.x);
|
||||
writer.WritePropertyName(nameof(value.y));
|
||||
writer.WriteValue(value.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7aaf0269bdd21d44db597cae952fc7f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,55 @@
|
||||
#region License
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2020 Wanzyee Studio
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Newtonsoft.Json.UnityConverters.Math
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom Newtonsoft.Json converter <see cref="JsonConverter"/> for the Unity integer Vector2 type <see cref="Vector2Int"/>.
|
||||
/// </summary>
|
||||
public class Vector2IntConverter : PartialConverter<Vector2Int>
|
||||
{
|
||||
protected override void ReadValue(ref Vector2Int value, string name, JsonReader reader, JsonSerializer serializer)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case nameof(value.x):
|
||||
value.x = reader.ReadAsInt32() ?? 0;
|
||||
break;
|
||||
case nameof(value.y):
|
||||
value.y = reader.ReadAsInt32() ?? 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void WriteJsonProperties(JsonWriter writer, Vector2Int value, JsonSerializer serializer)
|
||||
{
|
||||
writer.WritePropertyName(nameof(value.x));
|
||||
writer.WriteValue(value.x);
|
||||
writer.WritePropertyName(nameof(value.y));
|
||||
writer.WriteValue(value.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 160fce3550ff5d14ca68d1ca3127a074
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,61 @@
|
||||
#region License
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2020 Wanzyee Studio
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using Newtonsoft.Json.UnityConverters.Helpers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Newtonsoft.Json.UnityConverters.Math
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom Newtonsoft.Json converter <see cref="JsonConverter"/> for the Unity Vector3 type <see cref="Vector3"/>.
|
||||
/// </summary>
|
||||
public class Vector3Converter : PartialConverter<Vector3>
|
||||
{
|
||||
protected override void ReadValue(ref Vector3 value, string name, JsonReader reader, JsonSerializer serializer)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case nameof(value.x):
|
||||
value.x = reader.ReadAsFloat() ?? 0f;
|
||||
break;
|
||||
case nameof(value.y):
|
||||
value.y = reader.ReadAsFloat() ?? 0f;
|
||||
break;
|
||||
case nameof(value.z):
|
||||
value.z = reader.ReadAsFloat() ?? 0f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void WriteJsonProperties(JsonWriter writer, Vector3 value, JsonSerializer serializer)
|
||||
{
|
||||
writer.WritePropertyName(nameof(value.x));
|
||||
writer.WriteValue(value.x);
|
||||
writer.WritePropertyName(nameof(value.y));
|
||||
writer.WriteValue(value.y);
|
||||
writer.WritePropertyName(nameof(value.z));
|
||||
writer.WriteValue(value.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46a66d20df7340e459c3cd51e3a8b981
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,60 @@
|
||||
#region License
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2020 Wanzyee Studio
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Newtonsoft.Json.UnityConverters.Math
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom Newtonsoft.Json converter <see cref="JsonConverter"/> for the Unity integer Vector3 type <see cref="Vector3Int"/>.
|
||||
/// </summary>
|
||||
public class Vector3IntConverter : PartialConverter<Vector3Int>
|
||||
{
|
||||
protected override void ReadValue(ref Vector3Int value, string name, JsonReader reader, JsonSerializer serializer)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case nameof(value.x):
|
||||
value.x = reader.ReadAsInt32() ?? 0;
|
||||
break;
|
||||
case nameof(value.y):
|
||||
value.y = reader.ReadAsInt32() ?? 0;
|
||||
break;
|
||||
case nameof(value.z):
|
||||
value.z = reader.ReadAsInt32() ?? 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void WriteJsonProperties(JsonWriter writer, Vector3Int value, JsonSerializer serializer)
|
||||
{
|
||||
writer.WritePropertyName(nameof(value.x));
|
||||
writer.WriteValue(value.x);
|
||||
writer.WritePropertyName(nameof(value.y));
|
||||
writer.WriteValue(value.y);
|
||||
writer.WritePropertyName(nameof(value.z));
|
||||
writer.WriteValue(value.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3aa261b7b6ba3684ca1259adb20d54c8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
#region License
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2020 Wanzyee Studio
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using Newtonsoft.Json.UnityConverters.Helpers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Newtonsoft.Json.UnityConverters.Math
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom Newtonsoft.Json converter <see cref="JsonConverter"/> for the Unity Vector4 type <see cref="Vector4"/>.
|
||||
/// </summary>
|
||||
public class Vector4Converter : PartialConverter<Vector4>
|
||||
{
|
||||
protected override void ReadValue(ref Vector4 value, string name, JsonReader reader, JsonSerializer serializer)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case nameof(value.x):
|
||||
value.x = reader.ReadAsFloat() ?? 0f;
|
||||
break;
|
||||
case nameof(value.y):
|
||||
value.y = reader.ReadAsFloat() ?? 0f;
|
||||
break;
|
||||
case nameof(value.z):
|
||||
value.z = reader.ReadAsFloat() ?? 0f;
|
||||
break;
|
||||
case nameof(value.w):
|
||||
value.w = reader.ReadAsFloat() ?? 0f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void WriteJsonProperties(JsonWriter writer, Vector4 value, JsonSerializer serializer)
|
||||
{
|
||||
writer.WritePropertyName(nameof(value.x));
|
||||
writer.WriteValue(value.x);
|
||||
writer.WritePropertyName(nameof(value.y));
|
||||
writer.WriteValue(value.y);
|
||||
writer.WritePropertyName(nameof(value.z));
|
||||
writer.WriteValue(value.z);
|
||||
writer.WritePropertyName(nameof(value.w));
|
||||
writer.WriteValue(value.w);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de357adfe7b8e214986a440c88a576c9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user