From f049177e20a276049c61edbad631c1b2bbdd5706 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 15 Oct 2020 19:05:22 +0800 Subject: -advanced inspector +odin --- .../Odin Inspector/Scripts/VectorIntFormatters.cs | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Assets/Plugins/Sirenix/Odin Inspector/Scripts/VectorIntFormatters.cs (limited to 'Assets/Plugins/Sirenix/Odin Inspector/Scripts/VectorIntFormatters.cs') diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/VectorIntFormatters.cs b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/VectorIntFormatters.cs new file mode 100644 index 00000000..ccb62ce0 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/VectorIntFormatters.cs @@ -0,0 +1,80 @@ +#if UNITY_2017_2_OR_NEWER + +//----------------------------------------------------------------------- +// +// Copyright (c) Sirenix IVS. All rights reserved. +// +//----------------------------------------------------------------------- + +[assembly: Sirenix.Serialization.RegisterFormatter(typeof(Sirenix.Serialization.Vector2IntFormatter))] +[assembly: Sirenix.Serialization.RegisterFormatter(typeof(Sirenix.Serialization.Vector3IntFormatter))] +namespace Sirenix.Serialization +{ + using UnityEngine; + + /// + /// Custom formatter for the type. + /// + /// + public class Vector2IntFormatter : MinimalBaseFormatter + { + private static readonly Serializer Serializer = Serialization.Serializer.Get(); + + /// + /// Reads into the specified value using the specified reader. + /// + /// The value to read into. + /// The reader to use. + protected override void Read(ref Vector2Int value, IDataReader reader) + { + value.x = Vector2IntFormatter.Serializer.ReadValue(reader); + value.y = Vector2IntFormatter.Serializer.ReadValue(reader); + } + + /// + /// Writes from the specified value using the specified writer. + /// + /// The value to write from. + /// The writer to use. + protected override void Write(ref Vector2Int value, IDataWriter writer) + { + Vector2IntFormatter.Serializer.WriteValue(value.x, writer); + Vector2IntFormatter.Serializer.WriteValue(value.y, writer); + } + } + + /// + /// Custom formatter for the type. + /// + /// + public class Vector3IntFormatter : MinimalBaseFormatter + { + private static readonly Serializer Serializer = Serialization.Serializer.Get(); + + /// + /// Reads into the specified value using the specified reader. + /// + /// The value to read into. + /// The reader to use. + protected override void Read(ref Vector3Int value, IDataReader reader) + { + value.x = Vector3IntFormatter.Serializer.ReadValue(reader); + value.y = Vector3IntFormatter.Serializer.ReadValue(reader); + value.z = Vector3IntFormatter.Serializer.ReadValue(reader); + } + + /// + /// Writes from the specified value using the specified writer. + /// + /// The value to write from. + /// The writer to use. + protected override void Write(ref Vector3Int value, IDataWriter writer) + { + Vector3IntFormatter.Serializer.WriteValue(value.x, writer); + Vector3IntFormatter.Serializer.WriteValue(value.y, writer); + Vector3IntFormatter.Serializer.WriteValue(value.z, writer); + } + } +} + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0