Add VRChat and GitHub packages to Unity project
This commit is contained in:
1 parent
0334a52b21
commit
85538aaccc
3297 files changed
+847877
No files matched your search
+73
@@ -0,0 +1,73 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="AnimationCurveFormatter.cs" company="Sirenix IVS">
|
||||
// Copyright (c) 2018 Sirenix IVS
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using VRC.Udon.Serialization.OdinSerializer;
|
||||
|
||||
[assembly: RegisterFormatter(typeof(AnimationCurveFormatter))]
|
||||
|
||||
namespace VRC.Udon.Serialization.OdinSerializer
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom formatter for the <see cref="AnimationCurve"/> type.
|
||||
/// </summary>
|
||||
/// <seealso cref="MinimalBaseFormatter{UnityEngine.AnimationCurve}" />
|
||||
public class AnimationCurveFormatter : MinimalBaseFormatter<AnimationCurve>
|
||||
{
|
||||
private static readonly Serializer<Keyframe[]> KeyframeSerializer = Serializer.Get<Keyframe[]>();
|
||||
private static readonly Serializer<WrapMode> WrapModeSerializer = Serializer.Get<WrapMode>();
|
||||
|
||||
/// <summary>
|
||||
/// Returns null.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A null value.
|
||||
/// </returns>
|
||||
protected override AnimationCurve GetUninitializedObject()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads into the specified value using the specified reader.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to read into.</param>
|
||||
/// <param name="reader">The reader to use.</param>
|
||||
protected override void Read(ref AnimationCurve value, IDataReader reader)
|
||||
{
|
||||
var keys = KeyframeSerializer.ReadValue(reader);
|
||||
|
||||
value = new AnimationCurve(keys);
|
||||
value.preWrapMode = WrapModeSerializer.ReadValue(reader);
|
||||
value.postWrapMode = WrapModeSerializer.ReadValue(reader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes from the specified value using the specified writer.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write from.</param>
|
||||
/// <param name="writer">The writer to use.</param>
|
||||
protected override void Write(ref AnimationCurve value, IDataWriter writer)
|
||||
{
|
||||
KeyframeSerializer.WriteValue(value.keys, writer);
|
||||
WrapModeSerializer.WriteValue(value.preWrapMode, writer);
|
||||
WrapModeSerializer.WriteValue(value.postWrapMode, writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d2976bd61cccf62b11b4d3f02762465
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="BoundsFormatter.cs" company="Sirenix IVS">
|
||||
// Copyright (c) 2018 Sirenix IVS
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using VRC.Udon.Serialization.OdinSerializer;
|
||||
|
||||
[assembly: RegisterFormatter(typeof(BoundsFormatter))]
|
||||
|
||||
namespace VRC.Udon.Serialization.OdinSerializer
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom formatter for the <see cref="Bounds"/> type.
|
||||
/// </summary>
|
||||
/// <seealso cref="MinimalBaseFormatter{UnityEngine.Bounds}" />
|
||||
public class BoundsFormatter : MinimalBaseFormatter<Bounds>
|
||||
{
|
||||
private static readonly Serializer<Vector3> Vector3Serializer = Serializer.Get<Vector3>();
|
||||
|
||||
/// <summary>
|
||||
/// Reads into the specified value using the specified reader.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to read into.</param>
|
||||
/// <param name="reader">The reader to use.</param>
|
||||
protected override void Read(ref Bounds value, IDataReader reader)
|
||||
{
|
||||
value.center = Vector3Serializer.ReadValue(reader);
|
||||
value.size = Vector3Serializer.ReadValue(reader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes from the specified value using the specified writer.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write from.</param>
|
||||
/// <param name="writer">The writer to use.</param>
|
||||
protected override void Write(ref Bounds value, IDataWriter writer)
|
||||
{
|
||||
Vector3Serializer.WriteValue(value.center, writer);
|
||||
Vector3Serializer.WriteValue(value.size, writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ff1b29d64402a15d020739becd8661e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="Color32Formatter.cs" company="Sirenix IVS">
|
||||
// Copyright (c) 2018 Sirenix IVS
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using VRC.Udon.Serialization.OdinSerializer;
|
||||
|
||||
[assembly: RegisterFormatter(typeof(Color32Formatter))]
|
||||
|
||||
namespace VRC.Udon.Serialization.OdinSerializer
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom formatter for the <see cref="Color32"/> type.
|
||||
/// </summary>
|
||||
/// <seealso cref="MinimalBaseFormatter{UnityEngine.Color32}" />
|
||||
public class Color32Formatter : MinimalBaseFormatter<Color32>
|
||||
{
|
||||
private static readonly Serializer<byte> ByteSerializer = Serializer.Get<byte>();
|
||||
|
||||
/// <summary>
|
||||
/// Reads into the specified value using the specified reader.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to read into.</param>
|
||||
/// <param name="reader">The reader to use.</param>
|
||||
protected override void Read(ref Color32 value, IDataReader reader)
|
||||
{
|
||||
value.r = Color32Formatter.ByteSerializer.ReadValue(reader);
|
||||
value.g = Color32Formatter.ByteSerializer.ReadValue(reader);
|
||||
value.b = Color32Formatter.ByteSerializer.ReadValue(reader);
|
||||
value.a = Color32Formatter.ByteSerializer.ReadValue(reader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes from the specified value using the specified writer.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write from.</param>
|
||||
/// <param name="writer">The writer to use.</param>
|
||||
protected override void Write(ref Color32 value, IDataWriter writer)
|
||||
{
|
||||
Color32Formatter.ByteSerializer.WriteValue(value.r, writer);
|
||||
Color32Formatter.ByteSerializer.WriteValue(value.g, writer);
|
||||
Color32Formatter.ByteSerializer.WriteValue(value.b, writer);
|
||||
Color32Formatter.ByteSerializer.WriteValue(value.a, writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0878ec68b6ab3c9ebc365b6d139e4840
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="ColorBlockFormatter.cs" company="Sirenix IVS">
|
||||
// Copyright (c) 2018 Sirenix IVS
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using VRC.Udon.Serialization.OdinSerializer;
|
||||
|
||||
[assembly: RegisterFormatterLocator(typeof(ColorBlockFormatterLocator))]
|
||||
|
||||
namespace VRC.Udon.Serialization.OdinSerializer
|
||||
{
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
public class ColorBlockFormatterLocator : IFormatterLocator
|
||||
{
|
||||
public bool TryGetFormatter(Type type, FormatterLocationStep step, ISerializationPolicy policy, out IFormatter formatter)
|
||||
{
|
||||
if (step == FormatterLocationStep.BeforeRegisteredFormatters && type.FullName == "UnityEngine.UI.ColorBlock")
|
||||
{
|
||||
var formatterType = typeof(ColorBlockFormatter<>).MakeGenericType(type);
|
||||
formatter = (IFormatter)Activator.CreateInstance(formatterType);
|
||||
return true;
|
||||
}
|
||||
|
||||
formatter = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom formatter for the <see cref="ColorBlock"/> type.
|
||||
/// </summary>
|
||||
/// <seealso cref="MinimalBaseFormatter{UnityEngine.UI.ColorBlock}" />
|
||||
public class ColorBlockFormatter<T> : MinimalBaseFormatter<T>
|
||||
{
|
||||
private static readonly Serializer<float> FloatSerializer = Serializer.Get<float>();
|
||||
private static readonly Serializer<Color> ColorSerializer = Serializer.Get<Color>();
|
||||
|
||||
private static readonly PropertyInfo normalColor = typeof(T).GetProperty("normalColor");
|
||||
private static readonly PropertyInfo highlightedColor = typeof(T).GetProperty("highlightedColor");
|
||||
private static readonly PropertyInfo pressedColor = typeof(T).GetProperty("pressedColor");
|
||||
private static readonly PropertyInfo disabledColor = typeof(T).GetProperty("disabledColor");
|
||||
private static readonly PropertyInfo colorMultiplier = typeof(T).GetProperty("colorMultiplier");
|
||||
private static readonly PropertyInfo fadeDuration = typeof(T).GetProperty("fadeDuration");
|
||||
|
||||
/// <summary>
|
||||
/// Reads into the specified value using the specified reader.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to read into.</param>
|
||||
/// <param name="reader">The reader to use.</param>
|
||||
protected override void Read(ref T value, IDataReader reader)
|
||||
{
|
||||
object boxed = value;
|
||||
|
||||
normalColor.SetValue(boxed, ColorSerializer.ReadValue(reader), null);
|
||||
highlightedColor.SetValue(boxed, ColorSerializer.ReadValue(reader), null);
|
||||
pressedColor.SetValue(boxed, ColorSerializer.ReadValue(reader), null);
|
||||
disabledColor.SetValue(boxed, ColorSerializer.ReadValue(reader), null);
|
||||
colorMultiplier.SetValue(boxed, FloatSerializer.ReadValue(reader), null);
|
||||
fadeDuration.SetValue(boxed, FloatSerializer.ReadValue(reader), null);
|
||||
|
||||
value = (T)boxed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes from the specified value using the specified writer.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write from.</param>
|
||||
/// <param name="writer">The writer to use.</param>
|
||||
protected override void Write(ref T value, IDataWriter writer)
|
||||
{
|
||||
ColorSerializer.WriteValue((Color)normalColor.GetValue(value, null), writer);
|
||||
ColorSerializer.WriteValue((Color)highlightedColor.GetValue(value, null), writer);
|
||||
ColorSerializer.WriteValue((Color)pressedColor.GetValue(value, null), writer);
|
||||
ColorSerializer.WriteValue((Color)disabledColor.GetValue(value, null), writer);
|
||||
FloatSerializer.WriteValue((float)colorMultiplier.GetValue(value, null), writer);
|
||||
FloatSerializer.WriteValue((float)fadeDuration.GetValue(value, null), writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25e35581ce6d1febd9ac41864a76ecdb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="ColorFormatter.cs" company="Sirenix IVS">
|
||||
// Copyright (c) 2018 Sirenix IVS
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using VRC.Udon.Serialization.OdinSerializer;
|
||||
|
||||
[assembly: RegisterFormatter(typeof(ColorFormatter))]
|
||||
|
||||
namespace VRC.Udon.Serialization.OdinSerializer
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom formatter for the <see cref="Color"/> type.
|
||||
/// </summary>
|
||||
/// <seealso cref="MinimalBaseFormatter{UnityEngine.Color}" />
|
||||
public class ColorFormatter : MinimalBaseFormatter<Color>
|
||||
{
|
||||
private static readonly Serializer<float> FloatSerializer = Serializer.Get<float>();
|
||||
|
||||
/// <summary>
|
||||
/// Reads into the specified value using the specified reader.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to read into.</param>
|
||||
/// <param name="reader">The reader to use.</param>
|
||||
protected override void Read(ref Color value, IDataReader reader)
|
||||
{
|
||||
value.r = ColorFormatter.FloatSerializer.ReadValue(reader);
|
||||
value.g = ColorFormatter.FloatSerializer.ReadValue(reader);
|
||||
value.b = ColorFormatter.FloatSerializer.ReadValue(reader);
|
||||
value.a = ColorFormatter.FloatSerializer.ReadValue(reader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes from the specified value using the specified writer.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write from.</param>
|
||||
/// <param name="writer">The writer to use.</param>
|
||||
protected override void Write(ref Color value, IDataWriter writer)
|
||||
{
|
||||
ColorFormatter.FloatSerializer.WriteValue(value.r, writer);
|
||||
ColorFormatter.FloatSerializer.WriteValue(value.g, writer);
|
||||
ColorFormatter.FloatSerializer.WriteValue(value.b, writer);
|
||||
ColorFormatter.FloatSerializer.WriteValue(value.a, writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 484768ba343a6a05522c29d81a4ce61d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="CoroutineFormatter.cs" company="Sirenix IVS">
|
||||
// Copyright (c) 2018 Sirenix IVS
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using VRC.Udon.Serialization.OdinSerializer;
|
||||
|
||||
[assembly: RegisterFormatter(typeof(CoroutineFormatter))]
|
||||
|
||||
namespace VRC.Udon.Serialization.OdinSerializer
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// <para>
|
||||
/// Custom formatter for the <see cref="Coroutine"/> type.
|
||||
/// This serializes nothing and always deserializes null,
|
||||
/// and only exists to ensure that no coroutine instances
|
||||
/// are ever created by the serialization system, since they
|
||||
/// will in almost all cases be invalid instances.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Invalid coroutine instances crash Unity instantly when
|
||||
/// they are garbage collected.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public sealed class CoroutineFormatter : IFormatter<Coroutine>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the type that the formatter can serialize.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The type that the formatter can serialize.
|
||||
/// </value>
|
||||
public Type SerializedType { get { return typeof(Coroutine); } }
|
||||
|
||||
/// <summary>
|
||||
/// Returns null.
|
||||
/// </summary>
|
||||
object IFormatter.Deserialize(IDataReader reader)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns null.
|
||||
/// </summary>
|
||||
public Coroutine Deserialize(IDataReader reader)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does nothing.
|
||||
/// </summary>
|
||||
public void Serialize(object value, IDataWriter writer)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does nothing.
|
||||
/// </summary>
|
||||
public void Serialize(Coroutine value, IDataWriter writer)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3968bef792c5668478ac01be7645b30
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="GradientAlphaKeyFormatter.cs" company="Sirenix IVS">
|
||||
// Copyright (c) 2018 Sirenix IVS
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using VRC.Udon.Serialization.OdinSerializer;
|
||||
|
||||
[assembly: RegisterFormatter(typeof(GradientAlphaKeyFormatter))]
|
||||
|
||||
namespace VRC.Udon.Serialization.OdinSerializer
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom formatter for the <see cref="GradientAlphaKey"/> type.
|
||||
/// </summary>
|
||||
/// <seealso cref="MinimalBaseFormatter{UnityEngine.GradientAlphaKey}" />
|
||||
public class GradientAlphaKeyFormatter : MinimalBaseFormatter<GradientAlphaKey>
|
||||
{
|
||||
private static readonly Serializer<float> FloatSerializer = Serializer.Get<float>();
|
||||
|
||||
/// <summary>
|
||||
/// Reads into the specified value using the specified reader.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to read into.</param>
|
||||
/// <param name="reader">The reader to use.</param>
|
||||
protected override void Read(ref GradientAlphaKey value, IDataReader reader)
|
||||
{
|
||||
value.alpha = GradientAlphaKeyFormatter.FloatSerializer.ReadValue(reader);
|
||||
value.time = GradientAlphaKeyFormatter.FloatSerializer.ReadValue(reader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes from the specified value using the specified writer.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write from.</param>
|
||||
/// <param name="writer">The writer to use.</param>
|
||||
protected override void Write(ref GradientAlphaKey value, IDataWriter writer)
|
||||
{
|
||||
GradientAlphaKeyFormatter.FloatSerializer.WriteValue(value.alpha, writer);
|
||||
GradientAlphaKeyFormatter.FloatSerializer.WriteValue(value.time, writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5b415c00da8157ac50b8f5543f0b1d9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="GradientColorKeyFormatter.cs" company="Sirenix IVS">
|
||||
// Copyright (c) 2018 Sirenix IVS
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using VRC.Udon.Serialization.OdinSerializer;
|
||||
|
||||
[assembly: RegisterFormatter(typeof(GradientColorKeyFormatter))]
|
||||
|
||||
namespace VRC.Udon.Serialization.OdinSerializer
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom formatter for the <see cref="GradientColorKey"/> type.
|
||||
/// </summary>
|
||||
/// <seealso cref="MinimalBaseFormatter{UnityEngine.GradientColorKey}" />
|
||||
public class GradientColorKeyFormatter : MinimalBaseFormatter<GradientColorKey>
|
||||
{
|
||||
private static readonly Serializer<Color> ColorSerializer = Serializer.Get<Color>();
|
||||
private static readonly Serializer<float> FloatSerializer = Serializer.Get<float>();
|
||||
|
||||
/// <summary>
|
||||
/// Reads into the specified value using the specified reader.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to read into.</param>
|
||||
/// <param name="reader">The reader to use.</param>
|
||||
protected override void Read(ref GradientColorKey value, IDataReader reader)
|
||||
{
|
||||
value.color = GradientColorKeyFormatter.ColorSerializer.ReadValue(reader);
|
||||
value.time = GradientColorKeyFormatter.FloatSerializer.ReadValue(reader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes from the specified value using the specified writer.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write from.</param>
|
||||
/// <param name="writer">The writer to use.</param>
|
||||
protected override void Write(ref GradientColorKey value, IDataWriter writer)
|
||||
{
|
||||
GradientColorKeyFormatter.ColorSerializer.WriteValue(value.color, writer);
|
||||
GradientColorKeyFormatter.FloatSerializer.WriteValue(value.time, writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8936a3e43078251682f18923139f7aee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="GradientFormatter.cs" company="Sirenix IVS">
|
||||
// Copyright (c) 2018 Sirenix IVS
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using VRC.Udon.Serialization.OdinSerializer;
|
||||
|
||||
[assembly: RegisterFormatter(typeof(GradientFormatter))]
|
||||
|
||||
namespace VRC.Udon.Serialization.OdinSerializer
|
||||
{
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom formatter for the <see cref="Gradient"/> type.
|
||||
/// </summary>
|
||||
/// <seealso cref="MinimalBaseFormatter{UnityEngine.Gradient}" />
|
||||
public class GradientFormatter : MinimalBaseFormatter<Gradient>
|
||||
{
|
||||
private static readonly Serializer<GradientAlphaKey[]> AlphaKeysSerializer = Serializer.Get<GradientAlphaKey[]>();
|
||||
private static readonly Serializer<GradientColorKey[]> ColorKeysSerializer = Serializer.Get<GradientColorKey[]>();
|
||||
|
||||
// The Gradient.mode member of type UnityEngine.GradientMode was added in a later version of Unity
|
||||
// Therefore we need to handle it using reflection, as it might not be there if Odin is running in an early version
|
||||
|
||||
private static readonly PropertyInfo ModeProperty = typeof(Gradient).GetProperty("mode", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
private static readonly Serializer<object> EnumSerializer = ModeProperty != null ? Serializer.Get<object>() : null;
|
||||
|
||||
protected override Gradient GetUninitializedObject()
|
||||
{
|
||||
return new Gradient();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads into the specified value using the specified reader.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to read into.</param>
|
||||
/// <param name="reader">The reader to use.</param>
|
||||
protected override void Read(ref Gradient value, IDataReader reader)
|
||||
{
|
||||
value.alphaKeys = GradientFormatter.AlphaKeysSerializer.ReadValue(reader);
|
||||
value.colorKeys = GradientFormatter.ColorKeysSerializer.ReadValue(reader);
|
||||
|
||||
string name;
|
||||
reader.PeekEntry(out name);
|
||||
|
||||
if (name == "mode")
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ModeProperty != null)
|
||||
{
|
||||
ModeProperty.SetValue(value, EnumSerializer.ReadValue(reader), null);
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.SkipEntry();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
reader.Context.Config.DebugContext.LogWarning("Failed to read Gradient.mode, due to Unity's API disallowing setting of this member on other threads than the main thread. Gradient.mode value will have been lost.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes from the specified value using the specified writer.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write from.</param>
|
||||
/// <param name="writer">The writer to use.</param>
|
||||
protected override void Write(ref Gradient value, IDataWriter writer)
|
||||
{
|
||||
GradientFormatter.AlphaKeysSerializer.WriteValue(value.alphaKeys, writer);
|
||||
GradientFormatter.ColorKeysSerializer.WriteValue(value.colorKeys, writer);
|
||||
|
||||
if (ModeProperty != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
EnumSerializer.WriteValue("mode", ModeProperty.GetValue(value, null), writer);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
writer.Context.Config.DebugContext.LogWarning("Failed to write Gradient.mode, due to Unity's API disallowing setting of this member on other threads than the main thread. Gradient.mode will have been lost upon deserialization.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5b54660d5342fd45e2e43775538879d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="KeyframeFormatter.cs" company="Sirenix IVS">
|
||||
// Copyright (c) 2018 Sirenix IVS
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using VRC.Udon.Serialization.OdinSerializer;
|
||||
|
||||
[assembly: RegisterFormatter(typeof(KeyframeFormatter))]
|
||||
|
||||
namespace VRC.Udon.Serialization.OdinSerializer
|
||||
{
|
||||
using VRC.Udon.Serialization.OdinSerializer.Utilities;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom formatter for the <see cref="Keyframe"/> type.
|
||||
/// </summary>
|
||||
/// <seealso cref="MinimalBaseFormatter{UnityEngine.Keyframe}" />
|
||||
public class KeyframeFormatter : MinimalBaseFormatter<Keyframe>
|
||||
{
|
||||
private static readonly Serializer<float> FloatSerializer = Serializer.Get<float>();
|
||||
private static readonly Serializer<int> IntSerializer = Serializer.Get<int>();
|
||||
|
||||
private static readonly bool Is_In_2018_1_Or_Above;
|
||||
private static IFormatter<Keyframe> Formatter;
|
||||
|
||||
static KeyframeFormatter()
|
||||
{
|
||||
Is_In_2018_1_Or_Above = typeof(Keyframe).GetProperty("weightedMode") != null;
|
||||
|
||||
if (Is_In_2018_1_Or_Above)
|
||||
{
|
||||
if (EmitUtilities.CanEmit)
|
||||
{
|
||||
Formatter = (IFormatter<Keyframe>)FormatterEmitter.GetEmittedFormatter(typeof(Keyframe), SerializationPolicies.Everything);
|
||||
}
|
||||
else
|
||||
{
|
||||
Formatter = new ReflectionFormatter<Keyframe>(SerializationPolicies.Everything);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads into the specified value using the specified reader.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to read into.</param>
|
||||
/// <param name="reader">The reader to use.</param>
|
||||
protected override void Read(ref Keyframe value, IDataReader reader)
|
||||
{
|
||||
string name;
|
||||
EntryType first = reader.PeekEntry(out name);
|
||||
|
||||
if (first == EntryType.Integer && name == "ver")
|
||||
{
|
||||
if (Formatter == null)
|
||||
{
|
||||
// We're deserializing 2018.1+ data in a lower version of Unity - so just give it a go
|
||||
Formatter = new ReflectionFormatter<Keyframe>(SerializationPolicies.Everything);
|
||||
}
|
||||
|
||||
int version;
|
||||
reader.ReadInt32(out version);
|
||||
|
||||
// Only one version so far, so ignore it for now
|
||||
value = Formatter.Deserialize(reader);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Legacy Keyframe deserialization code
|
||||
value.inTangent = KeyframeFormatter.FloatSerializer.ReadValue(reader);
|
||||
value.outTangent = KeyframeFormatter.FloatSerializer.ReadValue(reader);
|
||||
value.time = KeyframeFormatter.FloatSerializer.ReadValue(reader);
|
||||
value.value = KeyframeFormatter.FloatSerializer.ReadValue(reader);
|
||||
|
||||
#pragma warning disable 0618
|
||||
value.tangentMode = KeyframeFormatter.IntSerializer.ReadValue(reader);
|
||||
#pragma warning restore 0618
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes from the specified value using the specified writer.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write from.</param>
|
||||
/// <param name="writer">The writer to use.</param>
|
||||
protected override void Write(ref Keyframe value, IDataWriter writer)
|
||||
{
|
||||
if (Is_In_2018_1_Or_Above)
|
||||
{
|
||||
writer.WriteInt32("ver", 1);
|
||||
Formatter.Serialize(value, writer);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Legacy Keyframe serialization code
|
||||
KeyframeFormatter.FloatSerializer.WriteValue(value.inTangent, writer);
|
||||
KeyframeFormatter.FloatSerializer.WriteValue(value.outTangent, writer);
|
||||
KeyframeFormatter.FloatSerializer.WriteValue(value.time, writer);
|
||||
KeyframeFormatter.FloatSerializer.WriteValue(value.value, writer);
|
||||
|
||||
#pragma warning disable 0618
|
||||
KeyframeFormatter.IntSerializer.WriteValue(value.tangentMode, writer);
|
||||
#pragma warning restore 0618
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68ac0b27f571616d3ed26c23eef40c8c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="LayerMaskFormatter.cs" company="Sirenix IVS">
|
||||
// Copyright (c) 2018 Sirenix IVS
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using VRC.Udon.Serialization.OdinSerializer;
|
||||
|
||||
[assembly: RegisterFormatter(typeof(LayerMaskFormatter))]
|
||||
|
||||
namespace VRC.Udon.Serialization.OdinSerializer
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom formatter for the <see cref="LayerMask"/> type.
|
||||
/// </summary>
|
||||
/// <seealso cref="MinimalBaseFormatter{UnityEngine.LayerMask}" />
|
||||
public class LayerMaskFormatter : MinimalBaseFormatter<LayerMask>
|
||||
{
|
||||
private static readonly Serializer<int> IntSerializer = Serializer.Get<int>();
|
||||
|
||||
/// <summary>
|
||||
/// Reads into the specified value using the specified reader.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to read into.</param>
|
||||
/// <param name="reader">The reader to use.</param>
|
||||
protected override void Read(ref LayerMask value, IDataReader reader)
|
||||
{
|
||||
value.value = LayerMaskFormatter.IntSerializer.ReadValue(reader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes from the specified value using the specified writer.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write from.</param>
|
||||
/// <param name="writer">The writer to use.</param>
|
||||
protected override void Write(ref LayerMask value, IDataWriter writer)
|
||||
{
|
||||
LayerMaskFormatter.IntSerializer.WriteValue(value.value, writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: afc596cd95a1ac316024d16f6fec6536
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="QuaternionFormatter.cs" company="Sirenix IVS">
|
||||
// Copyright (c) 2018 Sirenix IVS
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using VRC.Udon.Serialization.OdinSerializer;
|
||||
|
||||
[assembly: RegisterFormatter(typeof(QuaternionFormatter))]
|
||||
|
||||
namespace VRC.Udon.Serialization.OdinSerializer
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom formatter for the <see cref="Quaternion"/> type.
|
||||
/// </summary>
|
||||
/// <seealso cref="MinimalBaseFormatter{UnityEngine.Quaternion}" />
|
||||
public class QuaternionFormatter : MinimalBaseFormatter<Quaternion>
|
||||
{
|
||||
private static readonly Serializer<float> FloatSerializer = Serializer.Get<float>();
|
||||
|
||||
/// <summary>
|
||||
/// Reads into the specified value using the specified reader.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to read into.</param>
|
||||
/// <param name="reader">The reader to use.</param>
|
||||
protected override void Read(ref Quaternion value, IDataReader reader)
|
||||
{
|
||||
value.x = QuaternionFormatter.FloatSerializer.ReadValue(reader);
|
||||
value.y = QuaternionFormatter.FloatSerializer.ReadValue(reader);
|
||||
value.z = QuaternionFormatter.FloatSerializer.ReadValue(reader);
|
||||
value.w = QuaternionFormatter.FloatSerializer.ReadValue(reader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes from the specified value using the specified writer.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write from.</param>
|
||||
/// <param name="writer">The writer to use.</param>
|
||||
protected override void Write(ref Quaternion value, IDataWriter writer)
|
||||
{
|
||||
QuaternionFormatter.FloatSerializer.WriteValue(value.x, writer);
|
||||
QuaternionFormatter.FloatSerializer.WriteValue(value.y, writer);
|
||||
QuaternionFormatter.FloatSerializer.WriteValue(value.z, writer);
|
||||
QuaternionFormatter.FloatSerializer.WriteValue(value.w, writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 558323987bf9b75943382a5faa093ee3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="RectFormatter.cs" company="Sirenix IVS">
|
||||
// Copyright (c) 2018 Sirenix IVS
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using VRC.Udon.Serialization.OdinSerializer;
|
||||
|
||||
[assembly: RegisterFormatter(typeof(RectFormatter))]
|
||||
|
||||
namespace VRC.Udon.Serialization.OdinSerializer
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom formatter for the <see cref="Rect"/> type.
|
||||
/// </summary>
|
||||
/// <seealso cref="MinimalBaseFormatter{UnityEngine.Rect}" />
|
||||
public class RectFormatter : MinimalBaseFormatter<Rect>
|
||||
{
|
||||
private static readonly Serializer<float> FloatSerializer = Serializer.Get<float>();
|
||||
|
||||
/// <summary>
|
||||
/// Reads into the specified value using the specified reader.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to read into.</param>
|
||||
/// <param name="reader">The reader to use.</param>
|
||||
protected override void Read(ref Rect value, IDataReader reader)
|
||||
{
|
||||
value.x = RectFormatter.FloatSerializer.ReadValue(reader);
|
||||
value.y = RectFormatter.FloatSerializer.ReadValue(reader);
|
||||
value.width = RectFormatter.FloatSerializer.ReadValue(reader);
|
||||
value.height = RectFormatter.FloatSerializer.ReadValue(reader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes from the specified value using the specified writer.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write from.</param>
|
||||
/// <param name="writer">The writer to use.</param>
|
||||
protected override void Write(ref Rect value, IDataWriter writer)
|
||||
{
|
||||
RectFormatter.FloatSerializer.WriteValue(value.x, writer);
|
||||
RectFormatter.FloatSerializer.WriteValue(value.y, writer);
|
||||
RectFormatter.FloatSerializer.WriteValue(value.width, writer);
|
||||
RectFormatter.FloatSerializer.WriteValue(value.height, writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 196809b991e565a48e3d4ad08cb30b5e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="UnityEventFormatter.cs" company="Sirenix IVS">
|
||||
// Copyright (c) 2018 Sirenix IVS
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using VRC.Udon.Serialization.OdinSerializer;
|
||||
|
||||
[assembly: RegisterFormatter(typeof(UnityEventFormatter<>))]
|
||||
|
||||
namespace VRC.Udon.Serialization.OdinSerializer
|
||||
{
|
||||
using UnityEngine.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Custom generic formatter for the <see cref="UnityEvent{T0}"/>, <see cref="UnityEvent{T0, T1}"/>, <see cref="UnityEvent{T0, T1, T2}"/> and <see cref="UnityEvent{T0, T1, T2, T3}"/> types.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of UnityEvent that this formatter can serialize and deserialize.</typeparam>
|
||||
/// <seealso cref="ReflectionFormatter{UnityEngine.Events.UnityEvent}" />
|
||||
public class UnityEventFormatter<T> : ReflectionFormatter<T> where T : UnityEventBase, new()
|
||||
{
|
||||
/// <summary>
|
||||
/// Get an uninitialized object of type <see cref="T" />.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// An uninitialized object of type <see cref="T" />.
|
||||
/// </returns>
|
||||
protected override T GetUninitializedObject()
|
||||
{
|
||||
return new T();
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c934302874ac3315ed322feefefa1f9c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="Vector2Formatter.cs" company="Sirenix IVS">
|
||||
// Copyright (c) 2018 Sirenix IVS
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using VRC.Udon.Serialization.OdinSerializer;
|
||||
|
||||
[assembly: RegisterFormatter(typeof(Vector2Formatter))]
|
||||
|
||||
namespace VRC.Udon.Serialization.OdinSerializer
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom formatter for the <see cref="Vector2"/> type.
|
||||
/// </summary>
|
||||
/// <seealso cref="MinimalBaseFormatter{UnityEngine.Vector2}" />
|
||||
public class Vector2Formatter : MinimalBaseFormatter<Vector2>
|
||||
{
|
||||
private static readonly Serializer<float> FloatSerializer = Serializer.Get<float>();
|
||||
|
||||
/// <summary>
|
||||
/// Reads into the specified value using the specified reader.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to read into.</param>
|
||||
/// <param name="reader">The reader to use.</param>
|
||||
protected override void Read(ref Vector2 value, IDataReader reader)
|
||||
{
|
||||
value.x = Vector2Formatter.FloatSerializer.ReadValue(reader);
|
||||
value.y = Vector2Formatter.FloatSerializer.ReadValue(reader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes from the specified value using the specified writer.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write from.</param>
|
||||
/// <param name="writer">The writer to use.</param>
|
||||
protected override void Write(ref Vector2 value, IDataWriter writer)
|
||||
{
|
||||
Vector2Formatter.FloatSerializer.WriteValue(value.x, writer);
|
||||
Vector2Formatter.FloatSerializer.WriteValue(value.y, writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70c675a7b4c71c685ee39d745ccb058b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="Vector3Formatter.cs" company="Sirenix IVS">
|
||||
// Copyright (c) 2018 Sirenix IVS
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using VRC.Udon.Serialization.OdinSerializer;
|
||||
|
||||
[assembly: RegisterFormatter(typeof(Vector3Formatter))]
|
||||
|
||||
namespace VRC.Udon.Serialization.OdinSerializer
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom formatter for the <see cref="Vector3"/> type.
|
||||
/// </summary>
|
||||
/// <seealso cref="MinimalBaseFormatter{UnityEngine.Vector3}" />
|
||||
public class Vector3Formatter : MinimalBaseFormatter<Vector3>
|
||||
{
|
||||
private static readonly Serializer<float> FloatSerializer = Serializer.Get<float>();
|
||||
|
||||
/// <summary>
|
||||
/// Reads into the specified value using the specified reader.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to read into.</param>
|
||||
/// <param name="reader">The reader to use.</param>
|
||||
protected override void Read(ref Vector3 value, IDataReader reader)
|
||||
{
|
||||
value.x = Vector3Formatter.FloatSerializer.ReadValue(reader);
|
||||
value.y = Vector3Formatter.FloatSerializer.ReadValue(reader);
|
||||
value.z = Vector3Formatter.FloatSerializer.ReadValue(reader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes from the specified value using the specified writer.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write from.</param>
|
||||
/// <param name="writer">The writer to use.</param>
|
||||
protected override void Write(ref Vector3 value, IDataWriter writer)
|
||||
{
|
||||
Vector3Formatter.FloatSerializer.WriteValue(value.x, writer);
|
||||
Vector3Formatter.FloatSerializer.WriteValue(value.y, writer);
|
||||
Vector3Formatter.FloatSerializer.WriteValue(value.z, writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da2644647af1368176103aa87de1dbaf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="Vector4Formatter.cs" company="Sirenix IVS">
|
||||
// Copyright (c) 2018 Sirenix IVS
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using VRC.Udon.Serialization.OdinSerializer;
|
||||
|
||||
[assembly: RegisterFormatter(typeof(Vector4Formatter))]
|
||||
|
||||
namespace VRC.Udon.Serialization.OdinSerializer
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom formatter for the <see cref="Vector4"/> type.
|
||||
/// </summary>
|
||||
/// <seealso cref="MinimalBaseFormatter{UnityEngine.Vector4}" />
|
||||
public class Vector4Formatter : MinimalBaseFormatter<Vector4>
|
||||
{
|
||||
private static readonly Serializer<float> FloatSerializer = Serializer.Get<float>();
|
||||
|
||||
/// <summary>
|
||||
/// Reads into the specified value using the specified reader.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to read into.</param>
|
||||
/// <param name="reader">The reader to use.</param>
|
||||
protected override void Read(ref Vector4 value, IDataReader reader)
|
||||
{
|
||||
value.x = Vector4Formatter.FloatSerializer.ReadValue(reader);
|
||||
value.y = Vector4Formatter.FloatSerializer.ReadValue(reader);
|
||||
value.z = Vector4Formatter.FloatSerializer.ReadValue(reader);
|
||||
value.w = Vector4Formatter.FloatSerializer.ReadValue(reader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes from the specified value using the specified writer.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write from.</param>
|
||||
/// <param name="writer">The writer to use.</param>
|
||||
protected override void Write(ref Vector4 value, IDataWriter writer)
|
||||
{
|
||||
Vector4Formatter.FloatSerializer.WriteValue(value.x, writer);
|
||||
Vector4Formatter.FloatSerializer.WriteValue(value.y, writer);
|
||||
Vector4Formatter.FloatSerializer.WriteValue(value.z, writer);
|
||||
Vector4Formatter.FloatSerializer.WriteValue(value.w, writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60afa8ede3981c383782a01ddc55e943
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user