Merge branch 'main' into pgd/20250311_merge

This commit is contained in:
geondo55
2025-03-11 09:45:12 +09:00
5 changed files with 878 additions and 45 deletions

View File

@@ -0,0 +1,34 @@
using UnityEngine;
using MessagePack;
using MessagePack.Formatters;
using MessagePack.Resolvers;
using System;
using System.Collections.Generic;
public class CustomMessagePackResolver : IFormatterResolver
{
public static readonly IFormatterResolver Instance = new CustomMessagePackResolver();
private static readonly Dictionary<Type, object> formatters = new Dictionary<Type, object>
{
{ typeof(XED.Asset.MaterialPropertyData), new MessagePack.Formatters.XED.Asset.MaterialPropertyDataFormatter() },
{ typeof(XED.Asset.ModelData), new MessagePack.Formatters.XED.Asset.ModelDataFormatter() },
{ typeof(XED.Asset.SaveData), new MessagePack.Formatters.XED.Asset.SaveDataFormatter() },
{ typeof(XED.Asset.SavedModelData), new MessagePack.Formatters.XED.Asset.SavedModelDataFormatter() },
{ typeof(XED.Asset.SerializableMesh), new MessagePack.Formatters.XED.Asset.SerializableMeshFormatter() },
{ typeof(XED.Asset.SerializableQuaternion), new MessagePack.Formatters.XED.Asset.SerializableQuaternionFormatter() },
{ typeof(XED.Asset.SerializableVector2), new MessagePack.Formatters.XED.Asset.SerializableVector2Formatter() },
{ typeof(XED.Asset.SerializableVector3), new MessagePack.Formatters.XED.Asset.SerializableVector3Formatter() },
{ typeof(XED.Asset.SubmeshData), new MessagePack.Formatters.XED.Asset.SubmeshDataFormatter() },
{ typeof(XED.Asset.TextureData), new MessagePack.Formatters.XED.Asset.TextureDataFormatter() },
{ typeof(XED.Asset.TransformData), new MessagePack.Formatters.XED.Asset.TransformDataFormatter() },
};
public IMessagePackFormatter<T> GetFormatter<T>()
{
if (formatters.TryGetValue(typeof(T), out var formatter))
{
return (IMessagePackFormatter<T>)formatter;
}
return StandardResolver.Instance.GetFormatter<T>();
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 47d35b011d941df44a78fe2904fcc881

View File

@@ -0,0 +1,758 @@
// <auto-generated>
// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT.
// </auto-generated>
#pragma warning disable 618
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
#pragma warning disable CS1591 // document public APIs
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
#pragma warning disable SA1649 // File name should match first type name
namespace MessagePack.Resolvers
{
public class GeneratedResolver : global::MessagePack.IFormatterResolver
{
public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver();
private GeneratedResolver()
{
}
public global::MessagePack.Formatters.IMessagePackFormatter<T> GetFormatter<T>()
{
return FormatterCache<T>.Formatter;
}
private static class FormatterCache<T>
{
internal static readonly global::MessagePack.Formatters.IMessagePackFormatter<T> Formatter;
static FormatterCache()
{
var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T));
if (f != null)
{
Formatter = (global::MessagePack.Formatters.IMessagePackFormatter<T>)f;
}
}
}
}
internal static class GeneratedResolverGetFormatterHelper
{
private static readonly global::System.Collections.Generic.Dictionary<global::System.Type, int> lookup;
static GeneratedResolverGetFormatterHelper()
{
lookup = new global::System.Collections.Generic.Dictionary<global::System.Type, int>(18)
{
{ typeof(global::XED.Asset.MaterialPropertyData[]), 0 },
{ typeof(global::XED.Asset.ModelData[]), 1 },
{ typeof(global::XED.Asset.SavedModelData[]), 2 },
{ typeof(global::XED.Asset.SerializableVector2[]), 3 },
{ typeof(global::XED.Asset.SerializableVector3[]), 4 },
{ typeof(global::XED.Asset.SubmeshData[]), 5 },
{ typeof(global::XED.Asset.TextureData[]), 6 },
{ typeof(global::XED.Asset.MaterialPropertyData), 7 },
{ typeof(global::XED.Asset.ModelData), 8 },
{ typeof(global::XED.Asset.SaveData), 9 },
{ typeof(global::XED.Asset.SavedModelData), 10 },
{ typeof(global::XED.Asset.SerializableMesh), 11 },
{ typeof(global::XED.Asset.SerializableQuaternion), 12 },
{ typeof(global::XED.Asset.SerializableVector2), 13 },
{ typeof(global::XED.Asset.SerializableVector3), 14 },
{ typeof(global::XED.Asset.SubmeshData), 15 },
{ typeof(global::XED.Asset.TextureData), 16 },
{ typeof(global::XED.Asset.TransformData), 17 },
};
}
internal static object GetFormatter(global::System.Type t)
{
int key;
if (!lookup.TryGetValue(t, out key))
{
return null;
}
switch (key)
{
case 0: return new global::MessagePack.Formatters.ArrayFormatter<global::XED.Asset.MaterialPropertyData>();
case 1: return new global::MessagePack.Formatters.ArrayFormatter<global::XED.Asset.ModelData>();
case 2: return new global::MessagePack.Formatters.ArrayFormatter<global::XED.Asset.SavedModelData>();
case 3: return new global::MessagePack.Formatters.ArrayFormatter<global::XED.Asset.SerializableVector2>();
case 4: return new global::MessagePack.Formatters.ArrayFormatter<global::XED.Asset.SerializableVector3>();
case 5: return new global::MessagePack.Formatters.ArrayFormatter<global::XED.Asset.SubmeshData>();
case 6: return new global::MessagePack.Formatters.ArrayFormatter<global::XED.Asset.TextureData>();
case 7: return new MessagePack.Formatters.XED.Asset.MaterialPropertyDataFormatter();
case 8: return new MessagePack.Formatters.XED.Asset.ModelDataFormatter();
case 9: return new MessagePack.Formatters.XED.Asset.SaveDataFormatter();
case 10: return new MessagePack.Formatters.XED.Asset.SavedModelDataFormatter();
case 11: return new MessagePack.Formatters.XED.Asset.SerializableMeshFormatter();
case 12: return new MessagePack.Formatters.XED.Asset.SerializableQuaternionFormatter();
case 13: return new MessagePack.Formatters.XED.Asset.SerializableVector2Formatter();
case 14: return new MessagePack.Formatters.XED.Asset.SerializableVector3Formatter();
case 15: return new MessagePack.Formatters.XED.Asset.SubmeshDataFormatter();
case 16: return new MessagePack.Formatters.XED.Asset.TextureDataFormatter();
case 17: return new MessagePack.Formatters.XED.Asset.TransformDataFormatter();
default: return null;
}
}
}
}
#pragma warning restore 168
#pragma warning restore 414
#pragma warning restore 618
#pragma warning restore 612
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
#pragma warning restore SA1649 // File name should match first type name
// <auto-generated>
// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT.
// </auto-generated>
#pragma warning disable 618
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
#pragma warning disable CS1591 // document public APIs
#pragma warning disable SA1129 // Do not use default value type constructor
#pragma warning disable SA1309 // Field names should not begin with underscore
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
#pragma warning disable SA1403 // File may only contain a single namespace
#pragma warning disable SA1649 // File name should match first type name
namespace MessagePack.Formatters.XED.Asset
{
public sealed class MaterialPropertyDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.MaterialPropertyData>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.MaterialPropertyData value, global::MessagePack.MessagePackSerializerOptions options)
{
if (value == null)
{
writer.WriteNil();
return;
}
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(11);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<float[]>(formatterResolver).Serialize(ref writer, value.baseColor, options);
writer.Write(value.metallic);
writer.Write(value.smoothness);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<float[]>(formatterResolver).Serialize(ref writer, value.emissionColor, options);
writer.Write(value.renderMode);
writer.Write(value.surfaceType);
writer.Write(value.blendMode);
writer.Write(value.occlusionStrength);
writer.Write(value.normalScale);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string[]>(formatterResolver).Serialize(ref writer, value.texTypes, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string[]>(formatterResolver).Serialize(ref writer, value.texUIDs, options);
}
public global::XED.Asset.MaterialPropertyData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
return null;
}
options.Security.DepthStep(ref reader);
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
var length = reader.ReadArrayHeader();
var ____result = new global::XED.Asset.MaterialPropertyData();
for (int i = 0; i < length; i++)
{
switch (i)
{
case 0:
____result.baseColor = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<float[]>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
____result.metallic = reader.ReadSingle();
break;
case 2:
____result.smoothness = reader.ReadSingle();
break;
case 3:
____result.emissionColor = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<float[]>(formatterResolver).Deserialize(ref reader, options);
break;
case 4:
____result.renderMode = reader.ReadInt32();
break;
case 5:
____result.surfaceType = reader.ReadInt32();
break;
case 6:
____result.blendMode = reader.ReadInt32();
break;
case 7:
____result.occlusionStrength = reader.ReadSingle();
break;
case 8:
____result.normalScale = reader.ReadSingle();
break;
case 9:
____result.texTypes = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string[]>(formatterResolver).Deserialize(ref reader, options);
break;
case 10:
____result.texUIDs = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string[]>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
break;
}
}
reader.Depth--;
return ____result;
}
}
public sealed class ModelDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.ModelData>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.ModelData value, global::MessagePack.MessagePackSerializerOptions options)
{
if (value == null)
{
writer.WriteNil();
return;
}
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(3);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.TransformData>(formatterResolver).Serialize(ref writer, value.transformData, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableMesh>(formatterResolver).Serialize(ref writer, value.mesh, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.MaterialPropertyData[]>(formatterResolver).Serialize(ref writer, value.materialProperties, options);
}
public global::XED.Asset.ModelData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
return null;
}
options.Security.DepthStep(ref reader);
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
var length = reader.ReadArrayHeader();
var ____result = new global::XED.Asset.ModelData();
for (int i = 0; i < length; i++)
{
switch (i)
{
case 0:
____result.transformData = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.TransformData>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
____result.mesh = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableMesh>(formatterResolver).Deserialize(ref reader, options);
break;
case 2:
____result.materialProperties = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.MaterialPropertyData[]>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
break;
}
}
reader.Depth--;
return ____result;
}
}
public sealed class SaveDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.SaveData>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.SaveData value, global::MessagePack.MessagePackSerializerOptions options)
{
if (value == null)
{
writer.WriteNil();
return;
}
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(2);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SavedModelData[]>(formatterResolver).Serialize(ref writer, value.modelDatas, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.TextureData[]>(formatterResolver).Serialize(ref writer, value.textureDatas, options);
}
public global::XED.Asset.SaveData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
return null;
}
options.Security.DepthStep(ref reader);
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
var length = reader.ReadArrayHeader();
var ____result = new global::XED.Asset.SaveData();
for (int i = 0; i < length; i++)
{
switch (i)
{
case 0:
____result.modelDatas = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SavedModelData[]>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
____result.textureDatas = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.TextureData[]>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
break;
}
}
reader.Depth--;
return ____result;
}
}
public sealed class SavedModelDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.SavedModelData>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.SavedModelData value, global::MessagePack.MessagePackSerializerOptions options)
{
if (value == null)
{
writer.WriteNil();
return;
}
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(3);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.assetName, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.folderName, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.ModelData[]>(formatterResolver).Serialize(ref writer, value.models, options);
}
public global::XED.Asset.SavedModelData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
return null;
}
options.Security.DepthStep(ref reader);
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
var length = reader.ReadArrayHeader();
var ____result = new global::XED.Asset.SavedModelData();
for (int i = 0; i < length; i++)
{
switch (i)
{
case 0:
____result.assetName = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
____result.folderName = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
break;
case 2:
____result.models = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.ModelData[]>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
break;
}
}
reader.Depth--;
return ____result;
}
}
public sealed class SerializableMeshFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.SerializableMesh>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.SerializableMesh value, global::MessagePack.MessagePackSerializerOptions options)
{
if (value == null)
{
writer.WriteNil();
return;
}
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(4);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableVector3[]>(formatterResolver).Serialize(ref writer, value.vertices, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableVector3[]>(formatterResolver).Serialize(ref writer, value.normals, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableVector2[]>(formatterResolver).Serialize(ref writer, value.uv, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SubmeshData[]>(formatterResolver).Serialize(ref writer, value.submeshes, options);
}
public global::XED.Asset.SerializableMesh Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
return null;
}
options.Security.DepthStep(ref reader);
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
var length = reader.ReadArrayHeader();
var ____result = new global::XED.Asset.SerializableMesh();
for (int i = 0; i < length; i++)
{
switch (i)
{
case 0:
____result.vertices = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableVector3[]>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
____result.normals = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableVector3[]>(formatterResolver).Deserialize(ref reader, options);
break;
case 2:
____result.uv = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableVector2[]>(formatterResolver).Deserialize(ref reader, options);
break;
case 3:
____result.submeshes = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SubmeshData[]>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
break;
}
}
reader.Depth--;
return ____result;
}
}
public sealed class SerializableQuaternionFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.SerializableQuaternion>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.SerializableQuaternion value, global::MessagePack.MessagePackSerializerOptions options)
{
writer.WriteArrayHeader(4);
writer.Write(value.x);
writer.Write(value.y);
writer.Write(value.z);
writer.Write(value.w);
}
public global::XED.Asset.SerializableQuaternion Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
throw new global::System.InvalidOperationException("typecode is null, struct not supported");
}
options.Security.DepthStep(ref reader);
var length = reader.ReadArrayHeader();
var ____result = new global::XED.Asset.SerializableQuaternion();
for (int i = 0; i < length; i++)
{
switch (i)
{
case 0:
____result.x = reader.ReadSingle();
break;
case 1:
____result.y = reader.ReadSingle();
break;
case 2:
____result.z = reader.ReadSingle();
break;
case 3:
____result.w = reader.ReadSingle();
break;
default:
reader.Skip();
break;
}
}
reader.Depth--;
return ____result;
}
}
public sealed class SerializableVector2Formatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.SerializableVector2>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.SerializableVector2 value, global::MessagePack.MessagePackSerializerOptions options)
{
writer.WriteArrayHeader(2);
writer.Write(value.x);
writer.Write(value.y);
}
public global::XED.Asset.SerializableVector2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
throw new global::System.InvalidOperationException("typecode is null, struct not supported");
}
options.Security.DepthStep(ref reader);
var length = reader.ReadArrayHeader();
var __x__ = default(float);
var __y__ = default(float);
for (int i = 0; i < length; i++)
{
switch (i)
{
case 0:
__x__ = reader.ReadSingle();
break;
case 1:
__y__ = reader.ReadSingle();
break;
default:
reader.Skip();
break;
}
}
var ____result = new global::XED.Asset.SerializableVector2(__x__, __y__);
reader.Depth--;
return ____result;
}
}
public sealed class SerializableVector3Formatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.SerializableVector3>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.SerializableVector3 value, global::MessagePack.MessagePackSerializerOptions options)
{
writer.WriteArrayHeader(3);
writer.Write(value.x);
writer.Write(value.y);
writer.Write(value.z);
}
public global::XED.Asset.SerializableVector3 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
throw new global::System.InvalidOperationException("typecode is null, struct not supported");
}
options.Security.DepthStep(ref reader);
var length = reader.ReadArrayHeader();
var __x__ = default(float);
var __y__ = default(float);
var __z__ = default(float);
for (int i = 0; i < length; i++)
{
switch (i)
{
case 0:
__x__ = reader.ReadSingle();
break;
case 1:
__y__ = reader.ReadSingle();
break;
case 2:
__z__ = reader.ReadSingle();
break;
default:
reader.Skip();
break;
}
}
var ____result = new global::XED.Asset.SerializableVector3(__x__, __y__, __z__);
reader.Depth--;
return ____result;
}
}
public sealed class SubmeshDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.SubmeshData>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.SubmeshData value, global::MessagePack.MessagePackSerializerOptions options)
{
if (value == null)
{
writer.WriteNil();
return;
}
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(2);
writer.Write(value.materialIndex);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<int[]>(formatterResolver).Serialize(ref writer, value.triangles, options);
}
public global::XED.Asset.SubmeshData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
return null;
}
options.Security.DepthStep(ref reader);
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
var length = reader.ReadArrayHeader();
var ____result = new global::XED.Asset.SubmeshData();
for (int i = 0; i < length; i++)
{
switch (i)
{
case 0:
____result.materialIndex = reader.ReadInt32();
break;
case 1:
____result.triangles = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<int[]>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
break;
}
}
reader.Depth--;
return ____result;
}
}
public sealed class TextureDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.TextureData>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.TextureData value, global::MessagePack.MessagePackSerializerOptions options)
{
if (value == null)
{
writer.WriteNil();
return;
}
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(3);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.name, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.uid, options);
writer.Write(value.data);
}
public global::XED.Asset.TextureData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
return null;
}
options.Security.DepthStep(ref reader);
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
var length = reader.ReadArrayHeader();
var __name__ = default(string);
var __uid__ = default(string);
var __data__ = default(byte[]);
//var ____result = new global::XED.Asset.TextureData();
for (int i = 0; i < length; i++)
{
switch (i)
{
case 0:
//____result.name = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
__name__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
//____result.uid = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
__uid__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
break;
case 2:
//____result.data = global::MessagePack.Internal.CodeGenHelpers.GetArrayFromNullableSequence(reader.ReadBytes());
__data__ = global::MessagePack.Internal.CodeGenHelpers.GetArrayFromNullableSequence(reader.ReadBytes());
break;
default:
reader.Skip();
break;
}
}
var ____result = new global::XED.Asset.TextureData(__name__, __uid__, __data__);
reader.Depth--;
return ____result;
}
}
public sealed class TransformDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.TransformData>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.TransformData value, global::MessagePack.MessagePackSerializerOptions options)
{
if (value == null)
{
writer.WriteNil();
return;
}
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(3);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableVector3>(formatterResolver).Serialize(ref writer, value.position, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableQuaternion>(formatterResolver).Serialize(ref writer, value.rotation, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableVector3>(formatterResolver).Serialize(ref writer, value.scale, options);
}
public global::XED.Asset.TransformData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
return null;
}
options.Security.DepthStep(ref reader);
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
var length = reader.ReadArrayHeader();
var ____result = new global::XED.Asset.TransformData();
for (int i = 0; i < length; i++)
{
switch (i)
{
case 0:
____result.position = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableVector3>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
____result.rotation = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableQuaternion>(formatterResolver).Deserialize(ref reader, options);
break;
case 2:
____result.scale = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableVector3>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
break;
}
}
reader.Depth--;
return ____result;
}
}
}
#pragma warning restore 168
#pragma warning restore 414
#pragma warning restore 618
#pragma warning restore 612
#pragma warning restore SA1129 // Do not use default value type constructor
#pragma warning restore SA1309 // Field names should not begin with underscore
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
#pragma warning restore SA1403 // File may only contain a single namespace
#pragma warning restore SA1649 // File name should match first type name

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: bab1dbb292003874992b64c18aaea648

View File

@@ -12,6 +12,7 @@ using Newtonsoft.Json;
using System.Text;
using System.Linq;
using UnityEngine.EventSystems;
using MessagePack.Resolvers;
namespace XED.Asset
{
@@ -28,12 +29,14 @@ namespace XED.Asset
private SharedMaterial sharedMaterial;
private MessagePackFileManager<SaveData> fileManager;
private bool isSaveTaskComplete = true;
private bool isLoadTaskComplete = true;
private bool isLoadTaskComplete = true;
void Start()
{
saveData = new SaveData();
sharedMaterial = new SharedMaterial();
fileManager = new MessagePackFileManager<SaveData>();
fileManager.Initialize();
identifier = identifier.Length == 0 ? "defaultAssetData" : identifier;
StartCoroutine(CoroutineLoadLocalFiles());
string baseDataPath = Application.streamingAssetsPath + "/baseAssetData";
@@ -266,6 +269,7 @@ namespace XED.Asset
if (task.Result == null)
{
Debug.LogError("Error on loading local data.");
Debug.LogError("Error file location : " + filePath);
isLoadTaskComplete = true;
yield break;
}
@@ -574,6 +578,13 @@ namespace XED.Asset
{
dicTextureIDs[tex] = texUID;
Texture2D readableTex = GetReadableTexture(tex);
//TextureData textureData = new TextureData()
//{
// name = tex.name,
// uid = texUID,
// data = readableTex.EncodeToPNG()
//};
//textureDatas.Add(textureData);
textureDatas.Add(new TextureData(tex.name, texUID, readableTex.EncodeToPNG()));
}
return texUID;
@@ -597,19 +608,19 @@ namespace XED.Asset
[MessagePackObject]
public class SaveData
{
[Key("ModelData")]
[Key(0)]
public SavedModelData[] modelDatas;
[Key("TextureData")]
[Key(1)]
public TextureData[] textureDatas;
}
[MessagePackObject]
public class SavedModelData
{
[Key("AssetName")]
[Key(0)]
public string assetName;
[Key("FolderName")]
[Key(1)]
public string folderName;
[Key("ModelArray")]
[Key(2)]
public ModelData[] models;
public void SaveData(GameObject modelObject, SharedMaterial sharedMaterial)
{
@@ -661,21 +672,21 @@ namespace XED.Asset
[MessagePackObject]
public class ModelData
{
[Key("TransformData")]
[Key(0)]
public TransformData transformData;
[Key("MeshData")]
[Key(1)]
public SerializableMesh mesh;
[Key("MaterialData")]
[Key(2)]
public MaterialPropertyData[] materialProperties;
}
[MessagePackObject]
public class TransformData
{
[Key("Position")]
[Key(0)]
public SerializableVector3 position;
[Key("Rotation")]
[Key(1)]
public SerializableQuaternion rotation;
[Key("Scale")]
[Key(2)]
public SerializableVector3 scale;
public void SetData(Transform transform)
{
@@ -697,13 +708,13 @@ namespace XED.Asset
[MessagePackObject]
public class SerializableMesh
{
[Key("Vertices")]
[Key(0)]
public SerializableVector3[] vertices;
[Key("Normals")]
[Key(1)]
public SerializableVector3[] normals;
[Key("UVs")]
[Key(2)]
public SerializableVector2[] uv;
[Key("Submeshes")]
[Key(3)]
public SubmeshData[] submeshes;
public void SetData(Mesh mesh)
{
@@ -740,20 +751,22 @@ namespace XED.Asset
[MessagePackObject]
public class SubmeshData
{
[Key("MaterialIndex")]
[Key(0)]
public int materialIndex;
[Key("Triangles")]
[Key(1)]
public int[] triangles;
}
[MessagePackObject]
public struct SerializableVector3
{
[Key("V3x")]
[Key(0)]
public float x;
[Key("V3y")]
[Key(1)]
public float y;
[Key("V3z")]
[Key(2)]
public float z;
[SerializationConstructor]
public SerializableVector3(float x, float y, float z)
{
this.x = x;
@@ -776,10 +789,12 @@ namespace XED.Asset
[MessagePackObject]
public struct SerializableVector2
{
[Key("V2x")]
[Key(0)]
public float x;
[Key("V2y")]
[Key(1)]
public float y;
[SerializationConstructor]
public SerializableVector2(float x, float y)
{
this.x = x;
@@ -801,13 +816,13 @@ namespace XED.Asset
[MessagePackObject]
public struct SerializableQuaternion
{
[Key("Qx")]
[Key(0)]
public float x;
[Key("Qy")]
[Key(1)]
public float y;
[Key("Qz")]
[Key(2)]
public float z;
[Key("Qw")]
[Key(3)]
public float w;
public void FromQuaternion(Quaternion q) { x = q.x; y = q.y; z = q.z; w = q.w; }
@@ -816,27 +831,27 @@ namespace XED.Asset
[MessagePackObject]
public class MaterialPropertyData
{
[Key("BaseColor")]
[Key(0)]
public float[] baseColor;
[Key("Metallic")]
[Key(1)]
public float metallic;
[Key("Smoothness")]
[Key(2)]
public float smoothness;
[Key("Emission")]
[Key(3)]
public float[] emissionColor;
[Key("RenderMode")]
[Key(4)]
public int renderMode;
[Key("SurfaceType")]
[Key(5)]
public int surfaceType;
[Key("BlendMode")]
[Key(6)]
public int blendMode;
[Key("OcclusionStrength")]
[Key(7)]
public float occlusionStrength;
[Key("NormalScale")]
[Key(8)]
public float normalScale;
[Key("TextureTypes")]
[Key(9)]
public string[] texTypes;
[Key("TextureUIDs")]
[Key(10)]
public string[] texUIDs;
public void SetData(Material material)
@@ -951,12 +966,14 @@ namespace XED.Asset
[MessagePackObject]
public class TextureData
{
[Key("TextureName")]
[Key(0)]
public string name;
[Key("TextureUID")]
[Key(1)]
public string uid;
[Key("TextureData")]
[Key(2)]
public byte[] data;
[SerializationConstructor]
public TextureData(string name, string uid, byte[] data)
{
this.name = name;
@@ -967,10 +984,22 @@ namespace XED.Asset
}
public class MessagePackFileManager<T>
{
public void Initialize()
{
StaticCompositeResolver.Instance.Register(
GeneratedResolver.Instance,
StandardResolver.Instance
);
MessagePackSerializer.DefaultOptions = MessagePackSerializerOptions.Standard.WithResolver(
StaticCompositeResolver.Instance
);
}
public async Task<T> LoadAsync(string filePath)
{
var lz4Option = MessagePackSerializerOptions.Standard.WithCompression(MessagePackCompression.Lz4Block);
byte[] readByte;
var lz4Option = MessagePackSerializerOptions.Standard.
WithCompression(MessagePackCompression.Lz4Block).
WithResolver(StaticCompositeResolver.Instance);
byte[] readByte = null;
T deserailze = default(T);
try
{
@@ -980,13 +1009,21 @@ public class MessagePackFileManager<T>
catch (Exception ex)
{
Debug.LogError($"Task Error: {ex.Message}\n{ex.StackTrace}");
int byteLength = 0;
if (readByte != null)
{
byteLength = (int)readByte.Length;
}
Debug.LogError("Read Byte Size : " + byteLength.ToString());
}
return deserailze;
}
public async Task SaveAsync(string filePath, T data)
{
var lz4Option = MessagePackSerializerOptions.Standard.WithCompression(MessagePackCompression.Lz4Block);
var lz4Option = MessagePackSerializerOptions.Standard.
WithCompression(MessagePackCompression.Lz4Block).
WithResolver(StaticCompositeResolver.Instance);
try
{
byte[] bytes = MessagePackSerializer.Serialize<T>(data, lz4Option);
@@ -996,5 +1033,5 @@ public class MessagePackFileManager<T>
{
Debug.LogError($"Task Error: {ex.Message}\n{ex.StackTrace}");
}
}
}
}