1차 코드 리팩토링(ProjectManager)

This commit is contained in:
geondo55
2025-04-02 17:07:24 +09:00
parent c3c9b498c4
commit 3f40f681df
12 changed files with 400 additions and 241 deletions

View File

@@ -10,17 +10,17 @@ public class CustomMessagePackResolver : IFormatterResolver
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() },
{ typeof(XED.Manage.MaterialPropertyData), new MessagePack.Formatters.XED.Manage.MaterialPropertyDataFormatter() },
{ typeof(XED.Manage.ModelData), new MessagePack.Formatters.XED.Manage.ModelDataFormatter() },
{ typeof(XED.Manage.SaveData), new MessagePack.Formatters.XED.Manage.SaveDataFormatter() },
{ typeof(XED.Manage.SavedModelData), new MessagePack.Formatters.XED.Manage.SavedModelDataFormatter() },
{ typeof(XED.Manage.SerializableMesh), new MessagePack.Formatters.XED.Manage.SerializableMeshFormatter() },
{ typeof(XED.Manage.SerializableQuaternion), new MessagePack.Formatters.XED.Manage.SerializableQuaternionFormatter() },
{ typeof(XED.Manage.SerializableVector2), new MessagePack.Formatters.XED.Manage.SerializableVector2Formatter() },
{ typeof(XED.Manage.SerializableVector3), new MessagePack.Formatters.XED.Manage.SerializableVector3Formatter() },
{ typeof(XED.Manage.SubmeshData), new MessagePack.Formatters.XED.Manage.SubmeshDataFormatter() },
{ typeof(XED.Manage.TextureData), new MessagePack.Formatters.XED.Manage.TextureDataFormatter() },
{ typeof(XED.Manage.TransformData), new MessagePack.Formatters.XED.Manage.TransformDataFormatter() },
};
public IMessagePackFormatter<T> GetFormatter<T>()

View File

@@ -49,29 +49,29 @@ namespace MessagePack.Resolvers
{
lookup = new global::System.Collections.Generic.Dictionary<global::System.Type, int>(23)
{
{ 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.SerializableVector4[]), 5 },
{ typeof(global::XED.Asset.SubmeshData[]), 6 },
{ typeof(global::XED.Asset.TextureData[]), 7 },
{ typeof(global::XED.Asset.ThumbnailData[]), 8 },
{ typeof(global::XED.Manage.MaterialPropertyData[]), 0 },
{ typeof(global::XED.Manage.ModelData[]), 1 },
{ typeof(global::XED.Manage.SavedModelData[]), 2 },
{ typeof(global::XED.Manage.SerializableVector2[]), 3 },
{ typeof(global::XED.Manage.SerializableVector3[]), 4 },
{ typeof(global::XED.Manage.SerializableVector4[]), 5 },
{ typeof(global::XED.Manage.SubmeshData[]), 6 },
{ typeof(global::XED.Manage.TextureData[]), 7 },
{ typeof(global::XED.Manage.ThumbnailData[]), 8 },
{ typeof(string[][]), 9 },
{ typeof(global::XED.Asset.MaterialPropertyData), 10 },
{ typeof(global::XED.Asset.ModelData), 11 },
{ typeof(global::XED.Asset.SaveData), 12 },
{ typeof(global::XED.Asset.SavedModelData), 13 },
{ typeof(global::XED.Asset.SerializableMesh), 14 },
{ typeof(global::XED.Asset.SerializableQuaternion), 15 },
{ typeof(global::XED.Asset.SerializableVector2), 16 },
{ typeof(global::XED.Asset.SerializableVector3), 17 },
{ typeof(global::XED.Asset.SerializableVector4), 18 },
{ typeof(global::XED.Asset.SubmeshData), 19 },
{ typeof(global::XED.Asset.TextureData), 20 },
{ typeof(global::XED.Asset.ThumbnailData), 21 },
{ typeof(global::XED.Asset.TransformData), 22 },
{ typeof(global::XED.Manage.MaterialPropertyData), 10 },
{ typeof(global::XED.Manage.ModelData), 11 },
{ typeof(global::XED.Manage.SaveData), 12 },
{ typeof(global::XED.Manage.SavedModelData), 13 },
{ typeof(global::XED.Manage.SerializableMesh), 14 },
{ typeof(global::XED.Manage.SerializableQuaternion), 15 },
{ typeof(global::XED.Manage.SerializableVector2), 16 },
{ typeof(global::XED.Manage.SerializableVector3), 17 },
{ typeof(global::XED.Manage.SerializableVector4), 18 },
{ typeof(global::XED.Manage.SubmeshData), 19 },
{ typeof(global::XED.Manage.TextureData), 20 },
{ typeof(global::XED.Manage.ThumbnailData), 21 },
{ typeof(global::XED.Manage.TransformData), 22 },
};
}
@@ -85,29 +85,29 @@ namespace MessagePack.Resolvers
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.SerializableVector4>();
case 6: return new global::MessagePack.Formatters.ArrayFormatter<global::XED.Asset.SubmeshData>();
case 7: return new global::MessagePack.Formatters.ArrayFormatter<global::XED.Asset.TextureData>();
case 8: return new global::MessagePack.Formatters.ArrayFormatter<global::XED.Asset.ThumbnailData>();
case 0: return new global::MessagePack.Formatters.ArrayFormatter<global::XED.Manage.MaterialPropertyData>();
case 1: return new global::MessagePack.Formatters.ArrayFormatter<global::XED.Manage.ModelData>();
case 2: return new global::MessagePack.Formatters.ArrayFormatter<global::XED.Manage.SavedModelData>();
case 3: return new global::MessagePack.Formatters.ArrayFormatter<global::XED.Manage.SerializableVector2>();
case 4: return new global::MessagePack.Formatters.ArrayFormatter<global::XED.Manage.SerializableVector3>();
case 5: return new global::MessagePack.Formatters.ArrayFormatter<global::XED.Manage.SerializableVector4>();
case 6: return new global::MessagePack.Formatters.ArrayFormatter<global::XED.Manage.SubmeshData>();
case 7: return new global::MessagePack.Formatters.ArrayFormatter<global::XED.Manage.TextureData>();
case 8: return new global::MessagePack.Formatters.ArrayFormatter<global::XED.Manage.ThumbnailData>();
case 9: return new global::MessagePack.Formatters.ArrayFormatter<string[]>();
case 10: return new MessagePack.Formatters.XED.Asset.MaterialPropertyDataFormatter();
case 11: return new MessagePack.Formatters.XED.Asset.ModelDataFormatter();
case 12: return new MessagePack.Formatters.XED.Asset.SaveDataFormatter();
case 13: return new MessagePack.Formatters.XED.Asset.SavedModelDataFormatter();
case 14: return new MessagePack.Formatters.XED.Asset.SerializableMeshFormatter();
case 15: return new MessagePack.Formatters.XED.Asset.SerializableQuaternionFormatter();
case 16: return new MessagePack.Formatters.XED.Asset.SerializableVector2Formatter();
case 17: return new MessagePack.Formatters.XED.Asset.SerializableVector3Formatter();
case 18: return new MessagePack.Formatters.XED.Asset.SerializableVector4Formatter();
case 19: return new MessagePack.Formatters.XED.Asset.SubmeshDataFormatter();
case 20: return new MessagePack.Formatters.XED.Asset.TextureDataFormatter();
case 21: return new MessagePack.Formatters.XED.Asset.ThumbnailDataFormatter();
case 22: return new MessagePack.Formatters.XED.Asset.TransformDataFormatter();
case 10: return new MessagePack.Formatters.XED.Manage.MaterialPropertyDataFormatter();
case 11: return new MessagePack.Formatters.XED.Manage.ModelDataFormatter();
case 12: return new MessagePack.Formatters.XED.Manage.SaveDataFormatter();
case 13: return new MessagePack.Formatters.XED.Manage.SavedModelDataFormatter();
case 14: return new MessagePack.Formatters.XED.Manage.SerializableMeshFormatter();
case 15: return new MessagePack.Formatters.XED.Manage.SerializableQuaternionFormatter();
case 16: return new MessagePack.Formatters.XED.Manage.SerializableVector2Formatter();
case 17: return new MessagePack.Formatters.XED.Manage.SerializableVector3Formatter();
case 18: return new MessagePack.Formatters.XED.Manage.SerializableVector4Formatter();
case 19: return new MessagePack.Formatters.XED.Manage.SubmeshDataFormatter();
case 20: return new MessagePack.Formatters.XED.Manage.TextureDataFormatter();
case 21: return new MessagePack.Formatters.XED.Manage.ThumbnailDataFormatter();
case 22: return new MessagePack.Formatters.XED.Manage.TransformDataFormatter();
default: return null;
}
}
@@ -141,12 +141,12 @@ namespace MessagePack.Resolvers
#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
namespace MessagePack.Formatters.XED.Manage
{
public sealed class MaterialPropertyDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.MaterialPropertyData>
public sealed class MaterialPropertyDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Manage.MaterialPropertyData>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.MaterialPropertyData value, global::MessagePack.MessagePackSerializerOptions options)
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Manage.MaterialPropertyData value, global::MessagePack.MessagePackSerializerOptions options)
{
if (value == null)
{
@@ -169,7 +169,7 @@ namespace MessagePack.Formatters.XED.Asset
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)
public global::XED.Manage.MaterialPropertyData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -179,7 +179,7 @@ namespace MessagePack.Formatters.XED.Asset
options.Security.DepthStep(ref reader);
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
var length = reader.ReadArrayHeader();
var ____result = new global::XED.Asset.MaterialPropertyData();
var ____result = new global::XED.Manage.MaterialPropertyData();
for (int i = 0; i < length; i++)
{
@@ -229,10 +229,10 @@ namespace MessagePack.Formatters.XED.Asset
}
}
public sealed class ModelDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.ModelData>
public sealed class ModelDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Manage.ModelData>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.ModelData value, global::MessagePack.MessagePackSerializerOptions options)
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Manage.ModelData value, global::MessagePack.MessagePackSerializerOptions options)
{
if (value == null)
{
@@ -245,12 +245,12 @@ namespace MessagePack.Formatters.XED.Asset
writer.Write(value.id);
writer.Write(value.parentId);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Serialize(ref writer, value.modelComponentName, options);
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);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.TransformData>(formatterResolver).Serialize(ref writer, value.transformData, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SerializableMesh>(formatterResolver).Serialize(ref writer, value.mesh, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.MaterialPropertyData[]>(formatterResolver).Serialize(ref writer, value.materialProperties, options);
}
public global::XED.Asset.ModelData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
public global::XED.Manage.ModelData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -260,7 +260,7 @@ namespace MessagePack.Formatters.XED.Asset
options.Security.DepthStep(ref reader);
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
var length = reader.ReadArrayHeader();
var ____result = new global::XED.Asset.ModelData();
var ____result = new global::XED.Manage.ModelData();
for (int i = 0; i < length; i++)
{
@@ -276,13 +276,13 @@ namespace MessagePack.Formatters.XED.Asset
____result.modelComponentName = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string>(formatterResolver).Deserialize(ref reader, options);
break;
case 3:
____result.transformData = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.TransformData>(formatterResolver).Deserialize(ref reader, options);
____result.transformData = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.TransformData>(formatterResolver).Deserialize(ref reader, options);
break;
case 4:
____result.mesh = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableMesh>(formatterResolver).Deserialize(ref reader, options);
____result.mesh = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SerializableMesh>(formatterResolver).Deserialize(ref reader, options);
break;
case 5:
____result.materialProperties = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.MaterialPropertyData[]>(formatterResolver).Deserialize(ref reader, options);
____result.materialProperties = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.MaterialPropertyData[]>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
@@ -295,10 +295,10 @@ namespace MessagePack.Formatters.XED.Asset
}
}
public sealed class SaveDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.SaveData>
public sealed class SaveDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Manage.SaveData>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.SaveData value, global::MessagePack.MessagePackSerializerOptions options)
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Manage.SaveData value, global::MessagePack.MessagePackSerializerOptions options)
{
if (value == null)
{
@@ -308,12 +308,12 @@ namespace MessagePack.Formatters.XED.Asset
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(3);
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);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.ThumbnailData[]>(formatterResolver).Serialize(ref writer, value.thumbnailDatas, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SavedModelData[]>(formatterResolver).Serialize(ref writer, value.modelDatas, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.TextureData[]>(formatterResolver).Serialize(ref writer, value.textureDatas, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.ThumbnailData[]>(formatterResolver).Serialize(ref writer, value.thumbnailDatas, options);
}
public global::XED.Asset.SaveData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
public global::XED.Manage.SaveData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -323,20 +323,20 @@ namespace MessagePack.Formatters.XED.Asset
options.Security.DepthStep(ref reader);
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
var length = reader.ReadArrayHeader();
var ____result = new global::XED.Asset.SaveData();
var ____result = new global::XED.Manage.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);
____result.modelDatas = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SavedModelData[]>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
____result.textureDatas = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.TextureData[]>(formatterResolver).Deserialize(ref reader, options);
____result.textureDatas = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.TextureData[]>(formatterResolver).Deserialize(ref reader, options);
break;
case 2:
____result.thumbnailDatas = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.ThumbnailData[]>(formatterResolver).Deserialize(ref reader, options);
____result.thumbnailDatas = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.ThumbnailData[]>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
@@ -349,10 +349,10 @@ namespace MessagePack.Formatters.XED.Asset
}
}
public sealed class SavedModelDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.SavedModelData>
public sealed class SavedModelDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Manage.SavedModelData>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.SavedModelData value, global::MessagePack.MessagePackSerializerOptions options)
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Manage.SavedModelData value, global::MessagePack.MessagePackSerializerOptions options)
{
if (value == null)
{
@@ -363,10 +363,10 @@ namespace MessagePack.Formatters.XED.Asset
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(2);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string[][]>(formatterResolver).Serialize(ref writer, value.attributes, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.ModelData[]>(formatterResolver).Serialize(ref writer, value.models, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.ModelData[]>(formatterResolver).Serialize(ref writer, value.models, options);
}
public global::XED.Asset.SavedModelData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
public global::XED.Manage.SavedModelData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -376,7 +376,7 @@ namespace MessagePack.Formatters.XED.Asset
options.Security.DepthStep(ref reader);
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
var length = reader.ReadArrayHeader();
var ____result = new global::XED.Asset.SavedModelData();
var ____result = new global::XED.Manage.SavedModelData();
for (int i = 0; i < length; i++)
{
@@ -386,7 +386,7 @@ namespace MessagePack.Formatters.XED.Asset
____result.attributes = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<string[][]>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
____result.models = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.ModelData[]>(formatterResolver).Deserialize(ref reader, options);
____result.models = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.ModelData[]>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
@@ -399,10 +399,10 @@ namespace MessagePack.Formatters.XED.Asset
}
}
public sealed class SerializableMeshFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.SerializableMesh>
public sealed class SerializableMeshFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Manage.SerializableMesh>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.SerializableMesh value, global::MessagePack.MessagePackSerializerOptions options)
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Manage.SerializableMesh value, global::MessagePack.MessagePackSerializerOptions options)
{
if (value == null)
{
@@ -412,14 +412,14 @@ namespace MessagePack.Formatters.XED.Asset
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
writer.WriteArrayHeader(5);
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.SerializableVector4[]>(formatterResolver).Serialize(ref writer, value.tangents, 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);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SerializableVector3[]>(formatterResolver).Serialize(ref writer, value.vertices, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SerializableVector3[]>(formatterResolver).Serialize(ref writer, value.normals, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SerializableVector4[]>(formatterResolver).Serialize(ref writer, value.tangents, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SerializableVector2[]>(formatterResolver).Serialize(ref writer, value.uv, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SubmeshData[]>(formatterResolver).Serialize(ref writer, value.submeshes, options);
}
public global::XED.Asset.SerializableMesh Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
public global::XED.Manage.SerializableMesh Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -429,26 +429,26 @@ namespace MessagePack.Formatters.XED.Asset
options.Security.DepthStep(ref reader);
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
var length = reader.ReadArrayHeader();
var ____result = new global::XED.Asset.SerializableMesh();
var ____result = new global::XED.Manage.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);
____result.vertices = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SerializableVector3[]>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
____result.normals = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableVector3[]>(formatterResolver).Deserialize(ref reader, options);
____result.normals = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SerializableVector3[]>(formatterResolver).Deserialize(ref reader, options);
break;
case 2:
____result.tangents = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableVector4[]>(formatterResolver).Deserialize(ref reader, options);
____result.tangents = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SerializableVector4[]>(formatterResolver).Deserialize(ref reader, options);
break;
case 3:
____result.uv = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableVector2[]>(formatterResolver).Deserialize(ref reader, options);
____result.uv = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SerializableVector2[]>(formatterResolver).Deserialize(ref reader, options);
break;
case 4:
____result.submeshes = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SubmeshData[]>(formatterResolver).Deserialize(ref reader, options);
____result.submeshes = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SubmeshData[]>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();
@@ -461,10 +461,10 @@ namespace MessagePack.Formatters.XED.Asset
}
}
public sealed class SerializableQuaternionFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.SerializableQuaternion>
public sealed class SerializableQuaternionFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Manage.SerializableQuaternion>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.SerializableQuaternion value, global::MessagePack.MessagePackSerializerOptions options)
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Manage.SerializableQuaternion value, global::MessagePack.MessagePackSerializerOptions options)
{
writer.WriteArrayHeader(4);
writer.Write(value.x);
@@ -473,7 +473,7 @@ namespace MessagePack.Formatters.XED.Asset
writer.Write(value.w);
}
public global::XED.Asset.SerializableQuaternion Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
public global::XED.Manage.SerializableQuaternion Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -482,7 +482,7 @@ namespace MessagePack.Formatters.XED.Asset
options.Security.DepthStep(ref reader);
var length = reader.ReadArrayHeader();
var ____result = new global::XED.Asset.SerializableQuaternion();
var ____result = new global::XED.Manage.SerializableQuaternion();
for (int i = 0; i < length; i++)
{
@@ -511,17 +511,17 @@ namespace MessagePack.Formatters.XED.Asset
}
}
public sealed class SerializableVector2Formatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.SerializableVector2>
public sealed class SerializableVector2Formatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Manage.SerializableVector2>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.SerializableVector2 value, global::MessagePack.MessagePackSerializerOptions options)
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Manage.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)
public global::XED.Manage.SerializableVector2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -549,16 +549,16 @@ namespace MessagePack.Formatters.XED.Asset
}
}
var ____result = new global::XED.Asset.SerializableVector2(__x__, __y__);
var ____result = new global::XED.Manage.SerializableVector2(__x__, __y__);
reader.Depth--;
return ____result;
}
}
public sealed class SerializableVector3Formatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.SerializableVector3>
public sealed class SerializableVector3Formatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Manage.SerializableVector3>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.SerializableVector3 value, global::MessagePack.MessagePackSerializerOptions options)
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Manage.SerializableVector3 value, global::MessagePack.MessagePackSerializerOptions options)
{
writer.WriteArrayHeader(3);
writer.Write(value.x);
@@ -566,7 +566,7 @@ namespace MessagePack.Formatters.XED.Asset
writer.Write(value.z);
}
public global::XED.Asset.SerializableVector3 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
public global::XED.Manage.SerializableVector3 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -598,16 +598,16 @@ namespace MessagePack.Formatters.XED.Asset
}
}
var ____result = new global::XED.Asset.SerializableVector3(__x__, __y__, __z__);
var ____result = new global::XED.Manage.SerializableVector3(__x__, __y__, __z__);
reader.Depth--;
return ____result;
}
}
public sealed class SerializableVector4Formatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.SerializableVector4>
public sealed class SerializableVector4Formatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Manage.SerializableVector4>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.SerializableVector4 value, global::MessagePack.MessagePackSerializerOptions options)
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Manage.SerializableVector4 value, global::MessagePack.MessagePackSerializerOptions options)
{
writer.WriteArrayHeader(4);
writer.Write(value.x);
@@ -616,7 +616,7 @@ namespace MessagePack.Formatters.XED.Asset
writer.Write(value.w);
}
public global::XED.Asset.SerializableVector4 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
public global::XED.Manage.SerializableVector4 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -652,16 +652,16 @@ namespace MessagePack.Formatters.XED.Asset
}
}
var ____result = new global::XED.Asset.SerializableVector4(__x__, __y__, __z__, __w__);
var ____result = new global::XED.Manage.SerializableVector4(__x__, __y__, __z__, __w__);
reader.Depth--;
return ____result;
}
}
public sealed class SubmeshDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.SubmeshData>
public sealed class SubmeshDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Manage.SubmeshData>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.SubmeshData value, global::MessagePack.MessagePackSerializerOptions options)
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Manage.SubmeshData value, global::MessagePack.MessagePackSerializerOptions options)
{
if (value == null)
{
@@ -675,7 +675,7 @@ namespace MessagePack.Formatters.XED.Asset
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)
public global::XED.Manage.SubmeshData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -685,7 +685,7 @@ namespace MessagePack.Formatters.XED.Asset
options.Security.DepthStep(ref reader);
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
var length = reader.ReadArrayHeader();
var ____result = new global::XED.Asset.SubmeshData();
var ____result = new global::XED.Manage.SubmeshData();
for (int i = 0; i < length; i++)
{
@@ -708,10 +708,10 @@ namespace MessagePack.Formatters.XED.Asset
}
}
public sealed class TextureDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.TextureData>
public sealed class TextureDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Manage.TextureData>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.TextureData value, global::MessagePack.MessagePackSerializerOptions options)
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Manage.TextureData value, global::MessagePack.MessagePackSerializerOptions options)
{
if (value == null)
{
@@ -726,7 +726,7 @@ namespace MessagePack.Formatters.XED.Asset
writer.Write(value.data);
}
public global::XED.Asset.TextureData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
public global::XED.Manage.TextureData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -759,16 +759,16 @@ namespace MessagePack.Formatters.XED.Asset
}
}
var ____result = new global::XED.Asset.TextureData(__name__, __uid__, __data__);
var ____result = new global::XED.Manage.TextureData(__name__, __uid__, __data__);
reader.Depth--;
return ____result;
}
}
public sealed class ThumbnailDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.ThumbnailData>
public sealed class ThumbnailDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Manage.ThumbnailData>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.ThumbnailData value, global::MessagePack.MessagePackSerializerOptions options)
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Manage.ThumbnailData value, global::MessagePack.MessagePackSerializerOptions options)
{
if (value == null)
{
@@ -780,7 +780,7 @@ namespace MessagePack.Formatters.XED.Asset
writer.Write(value.data);
}
public global::XED.Asset.ThumbnailData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
public global::XED.Manage.ThumbnailData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -804,16 +804,16 @@ namespace MessagePack.Formatters.XED.Asset
}
}
var ____result = new global::XED.Asset.ThumbnailData(__data__);
var ____result = new global::XED.Manage.ThumbnailData(__data__);
reader.Depth--;
return ____result;
}
}
public sealed class TransformDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Asset.TransformData>
public sealed class TransformDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::XED.Manage.TransformData>
{
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Asset.TransformData value, global::MessagePack.MessagePackSerializerOptions options)
public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::XED.Manage.TransformData value, global::MessagePack.MessagePackSerializerOptions options)
{
if (value == null)
{
@@ -823,12 +823,12 @@ namespace MessagePack.Formatters.XED.Asset
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);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SerializableVector3>(formatterResolver).Serialize(ref writer, value.position, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SerializableQuaternion>(formatterResolver).Serialize(ref writer, value.rotation, options);
global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SerializableVector3>(formatterResolver).Serialize(ref writer, value.scale, options);
}
public global::XED.Asset.TransformData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
public global::XED.Manage.TransformData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
@@ -838,20 +838,20 @@ namespace MessagePack.Formatters.XED.Asset
options.Security.DepthStep(ref reader);
global::MessagePack.IFormatterResolver formatterResolver = options.Resolver;
var length = reader.ReadArrayHeader();
var ____result = new global::XED.Asset.TransformData();
var ____result = new global::XED.Manage.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);
____result.position = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SerializableVector3>(formatterResolver).Deserialize(ref reader, options);
break;
case 1:
____result.rotation = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableQuaternion>(formatterResolver).Deserialize(ref reader, options);
____result.rotation = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SerializableQuaternion>(formatterResolver).Deserialize(ref reader, options);
break;
case 2:
____result.scale = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Asset.SerializableVector3>(formatterResolver).Deserialize(ref reader, options);
____result.scale = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<global::XED.Manage.SerializableVector3>(formatterResolver).Deserialize(ref reader, options);
break;
default:
reader.Skip();

View File

@@ -73,6 +73,23 @@ namespace XED
CommandManager.I.ExecuteCommand(command);
}
public void OnCompletelyRemoveObject(List<CustomAssetRenderObject> objects)
{
if (objects.Count == 0)
{
return;
}
List<ConnectedAsset> removeList = new List<ConnectedAsset>();
List<int> siblingIndex = new List<int>();
for (int i = 0; i < objects.Count; i++)
{
ConnectedAsset searchAsset = connector.connectedAssets.Find((x) => x.renderObject == objects[i]);
removeList.Add(searchAsset);
siblingIndex.Add(searchAsset.hierarchyItem.GetSiblingIndex());
}
ExecuteCompletelyRemoveObject(removeList);
}
private void ExecuteRemoveObject(List<ConnectedAsset> removeList)
{
for (int i = 0; i < removeList.Count; i++)
@@ -94,6 +111,19 @@ namespace XED
connector.componentScrollView.DeselectAll();
}
private void ExecuteCompletelyRemoveObject(List<ConnectedAsset> removeList)
{
for (int i = 0; i < removeList.Count; i++)
{
ConnectedAsset connectedAsset = removeList[i];
connector.componentScrollView.RemoveItem(connectedAsset.hierarchyItem);
connectedAsset.assetData.RemoveTransform(connectedAsset.renderObject.transform);
connectedAsset.renderObject.gameObject.SetActive(false);
}
connector.onCompletelyRemoveObjects?.Invoke();
connector.componentScrollView.DeselectAll();
}
private void UndoRemoveObject(List<ConnectedAsset> removeList, List<int> siblingIndex)
{
for (int i = 0; i < removeList.Count; i++)

View File

@@ -31,6 +31,7 @@ namespace XED.Asset
public System.Action<string, List<GameObject>> onSelectObjects;
public System.Action onDeselectObjects;
public System.Action onRemoveObjects;
public System.Action onCompletelyRemoveObjects;
public System.Action onAssetDropped;
public CustomAssetDataHandler assetDataHandler;
@@ -71,7 +72,7 @@ namespace XED.Asset
renderObjectHandler.onOrderByHierachy.AddListener(OrderByHierarchy);
renderObjectHandler.onDeselectAll += OnDeselectAll;
projectManager.onRemoveAsset += assetCommandHandler.OnRemoveObject;
projectManager.onRemoveAsset += assetCommandHandler.OnCompletelyRemoveObject;
}
// Update is called once per frame

View File

@@ -160,6 +160,17 @@ namespace XED.Util
RemoveAllSelections();
onDeselectAll?.Invoke();
}
public void RemoveAll()
{
if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.LeftShift))
{
return;
}
CompletelyRemoveAllSelections();
onDeselectAll?.Invoke();
}
public void AddSelection(CustomAssetRenderObject item)
{
if (selectedRenderObjects.Any(x => x == item))
@@ -196,6 +207,18 @@ namespace XED.Util
selectedGameObjects.Clear();
rtgController.SetGizmoTargetObjects(selectedGameObjects);
}
public void CompletelyRemoveAllSelections()
{
for (int i = 0; i < selectedRenderObjects.Count; i++)
{
Debug.Log("enter");
selectedRenderObjects[i].Deselect();
Destroy(selectedRenderObjects[i].gameObject);
}
selectedRenderObjects.Clear();
selectedGameObjects.Clear();
rtgController.SetGizmoTargetObjects(selectedGameObjects);
}
public void RemoveSelection(CustomAssetRenderObject item)
{
selectedRenderObjects.Remove(item);

View File

@@ -0,0 +1,46 @@
using System.Collections.Generic;
using UnityEngine;
namespace XED.Util
{
public class ProjectData
{
public string filePath;
public string updateDate;
public List<AssetData> assetDatas;
}
public class AssetData
{
public int id;
public string name;
public SaveVector3 position;
public SaveVector3 rotation;
public SaveVector3 scale;
public List<int> children;
public AssetData(int id, string name, SaveVector3 position, SaveVector3 rotation, SaveVector3 scale, List<int> children)
{
this.id = id;
this.name = name;
this.position = position;
this.rotation = rotation;
this.scale = scale;
this.children = children;
}
}
public class SaveVector3
{
public float x;
public float y;
public float z;
public SaveVector3(Vector3 vector3)
{
x = vector3.x;
y = vector3.y;
z = vector3.z;
}
}
}

View File

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

View File

@@ -46,6 +46,7 @@ namespace XED.Manage
void ManagerConnection()
{
customAssetConnector.onRemoveObjects += renderObjectHandler.DeselectAll;
customAssetConnector.onCompletelyRemoveObjects += renderObjectHandler.RemoveAll;
customAssetConnector.onSelectObjects += ((name, objects) => { canvas_Popup.panel_objectinfo.gameObject.SetActive(true); });
customAssetConnector.onSelectObjects += canvas_Popup.panel_objectinfo.SetObjectInfo;
customAssetConnector.onSelectObjects += canvas_Popup.panel_objectdistance.SelectObjectFromClick;

View File

@@ -1,10 +1,16 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using TriLibCore.SFB;
using UnityEditor;
using UnityEditor.Build.Pipeline.WriteTypes;
using UnityEngine;
using UnityEngine.Rendering;
using XED.Asset;
using XED.Hierarchy;
using XED.Repositories;
using XED.Util;
using XRLib;
@@ -12,10 +18,12 @@ namespace XED.Manage
{
public class ProjectManager : MonoBehaviour, ISingle
{
private AssetDataService assetDataService;
private CustomAssetConnector connector;
private FileBrowserHandler fileBrowserHandler;
private string curProjectPath;
private SceneData curSceneData;
private ProjectData curProjectData;
Dictionary<int, HierarchyItem> itemDict = new Dictionary<int, HierarchyItem>();
public event Action<AssetData> onLoadAsset;
public event Action<HierarchyItem, HierarchyItem> onRestoreHierarchy;
@@ -23,140 +31,142 @@ namespace XED.Manage
public override void AfterAwake()
{
assetDataService = new AssetDataService();
connector = FindSingle<CustomAssetConnector>();
fileBrowserHandler = FindSingle<FileBrowserHandler>();
}
public void SaveProject()
{
bool isNewProject = string.IsNullOrEmpty(curProjectPath);
List<AssetData> assetInfos = connector.connectedAssets
.Where(asset => asset.hierarchyItem.linkedObject.activeSelf)
.OrderBy(asset => asset.hierarchyItem.layerNum)
.ThenBy(asset => asset.hierarchyItem.GetSiblingIndex())
.Select(asset => CreateAssetData(asset.hierarchyItem))
.ToList();
string path = isNewProject ? GetSaveFilePath() : curProjectData.filePath;
SceneData sceneData = new SceneData
if (string.IsNullOrEmpty(path))
return;
List<AssetData> assetDatas = assetDataService.SortAssetDatas(connector.connectedAssets);
ProjectData projectData = new ProjectData
{
createTime = isNewProject ? DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : curSceneData.createTime,
updateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
assetInfos = assetInfos
filePath = path,
updateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
assetDatas = assetDatas
};
if(isNewProject)
{
fileBrowserHandler.SaveFileBrowser(sceneData, "SaveProject", "ProjectName");
}
else
{
fileBrowserHandler.SaveFile(sceneData, curProjectPath);
}
curProjectPath = fileBrowserHandler.GetLastOpenFilePath();
if(!string.IsNullOrEmpty(curProjectPath))
{
curSceneData = sceneData;
}
}
private AssetData CreateAssetData(HierarchyItem hierarchyItem)
{
return new AssetData(
hierarchyItem.linkedObject.GetInstanceID(),
hierarchyItem.name,
new SaveVector3(hierarchyItem.linkedObject.transform.position),
new SaveVector3(hierarchyItem.linkedObject.transform.eulerAngles),
new SaveVector3(hierarchyItem.linkedObject.transform.localScale),
hierarchyItem.children.Select(x => x.linkedObject.GetInstanceID()).ToList()
);
SaveFile(path, projectData);
}
public void LoadProject()
{
SceneData sceneData = fileBrowserHandler.OpenFileBrowser<SceneData>("OpenProject");
if (sceneData == null || !FindAnyObjectByType<FBXFileManager>().isLoadTaskComplete)
if (!FindAnyObjectByType<FBXFileManager>().isLoadTaskComplete)
return;
NewProject();
curProjectPath = fileBrowserHandler.GetLastOpenFilePath();
curSceneData = sceneData;
Dictionary<int, HierarchyItem> itemDict = new Dictionary<int, HierarchyItem>();
string path = GetOpenFilePath();
foreach (AssetData asset in sceneData.assetInfos)
{
onLoadAsset?.Invoke(asset);
itemDict.Add(asset.id, connector.connectedAssets.Last().hierarchyItem);
}
if (string.IsNullOrEmpty(path))
return;
foreach (AssetData asset in sceneData.assetInfos)
{
foreach (int id in asset.children)
{
HierarchyItem parent = itemDict[asset.id];
HierarchyItem child = itemDict[id];
if (parent == null || child == null)
continue;
ProjectData projectData = GetFileData(path);
if (projectData == null)
return;
RemoveObject();
Init();
LoadAssets(projectData.assetDatas);
RestoreHierarchys(projectData.assetDatas);
onRestoreHierarchy?.Invoke(parent, child);
}
}
CommandManager.I.Clear();
curProjectPath = path;
curProjectData = projectData;
}
public void NewProject()
{
RemoveObject();
Init();
}
private void LoadAssets(List<AssetData> assets)
{
foreach (AssetData asset in assets)
{
LoadAsset(asset);
}
}
private void RestoreHierarchys(List<AssetData> assets)
{
foreach (AssetData asset in assets)
{
RestoreHierarchy(asset);
}
}
public void RemoveObject()
{
List<CustomAssetRenderObject> objects = connector.connectedAssets.Select(x => x.renderObject).ToList();
onRemoveAsset?.Invoke(objects);
onRemoveAsset?.Invoke(objects);
}
private void Init()
{
curProjectPath = string.Empty;
curSceneData = null;
curProjectData = null;
connector.connectedAssets.Clear();
CommandManager.I.Clear();
itemDict.Clear();
}
}
public class SceneData
{
public string createTime;
public string updateTime;
public List<AssetData> assetInfos;
}
public class AssetData
{
public int id;
public string name;
public SaveVector3 position;
public SaveVector3 rotation;
public SaveVector3 scale;
public List<int> children;
public AssetData(int id, string name, SaveVector3 position, SaveVector3 rotation, SaveVector3 scale, List<int> children)
public string GetSaveFilePath()
{
this.id = id;
this.name = name;
this.position = position;
this.rotation = rotation;
this.scale = scale;
this.children = children;
var data = StandaloneFileBrowser.SaveFilePanel("SaveProject", "", "", "json");
return data.Name;
}
}
public class SaveVector3
{
public float x;
public float y;
public float z;
public SaveVector3(Vector3 vector3)
public string GetOpenFilePath()
{
x = vector3.x;
y = vector3.y;
z = vector3.z;
var data = StandaloneFileBrowser.OpenFilePanel("OpenProject", "", "json", false);
return data.Count >= 1 ? data[0].Name : "";
}
}
public void SaveFile(string path, ProjectData data)
{
string json = JsonConvert.SerializeObject(data);
FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write);
StreamWriter writer = new StreamWriter(fs, System.Text.Encoding.Unicode);
writer.Write(json);
writer.Close();
curProjectPath = path;
curProjectData = data;
}
public ProjectData GetFileData(string path)
{
string json = File.ReadAllText(path);
return JsonConvert.DeserializeObject<ProjectData>(json);
}
private void LoadAsset(AssetData asset)
{
onLoadAsset?.Invoke(asset);
itemDict.Add(asset.id, connector.connectedAssets.Last().hierarchyItem);
}
private void RestoreHierarchy(AssetData asset)
{
foreach (int id in asset.children)
{
HierarchyItem parent = itemDict[asset.id];
HierarchyItem child = itemDict[id];
if (parent == null || child == null)
continue;
onRestoreHierarchy?.Invoke(parent, child);
}
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 229f65e4bb8676d41a04d9a838745d5e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
using System.Collections.Generic;
using System;
using UnityEngine;
using XED.Manage;
using XED.Util;
using XED.Asset;
using System.Linq;
using XED.Hierarchy;
namespace XED
{
public class AssetDataService
{
public List<AssetData> SortAssetDatas(List<ConnectedAsset> connectedAssets)
{
return connectedAssets
.Where(asset => asset.hierarchyItem.linkedObject.activeSelf)
.OrderBy(asset => asset.hierarchyItem.layerNum)
.ThenBy(asset => asset.hierarchyItem.GetSiblingIndex())
.Select(asset => CreateAssetData(asset.hierarchyItem))
.ToList();
}
public AssetData CreateAssetData(HierarchyItem hierarchyItem)
{
return new AssetData(
hierarchyItem.linkedObject.GetInstanceID(),
hierarchyItem.name,
new SaveVector3(hierarchyItem.linkedObject.transform.position),
new SaveVector3(hierarchyItem.linkedObject.transform.eulerAngles),
new SaveVector3(hierarchyItem.linkedObject.transform.localScale),
hierarchyItem.children.Select(x => x.linkedObject.GetInstanceID()).ToList()
);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 90919af16f583ed46add3dccc093f7c6