ExtensionSerialization

This commit is contained in:
ousttrue
2020-11-20 12:57:43 +09:00
parent 568ac29216
commit 913dd97554
5 changed files with 58 additions and 10 deletions

View File

@@ -0,0 +1,22 @@
using System;
using System.IO;
namespace UniGLTF
{
public class ExtensionSerialization : IValueSerialization
{
public Type ValueType => typeof(object);
public bool IsInline => true;
public void GenerateDeserializer(StreamWriter writer, string callName)
{
throw new System.NotImplementedException();
}
public string GenerateDeserializerCall(string callName, string argName)
{
return argName;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 827d441621713194c88a8c94b7b1c2f0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -126,6 +126,10 @@ namespace UniGLTF
{
return new EnumIntSerialization(t, attr.EnumSerializationType);
}
else if (t == typeof(object))
{
return new ExtensionSerialization();
}
return new ObjectSerialization(t, path);
}

View File

@@ -38,11 +38,6 @@ namespace UniGLTF
m_fsi = t.GetFields(DeserializerGenerator.FIELD_FLAGS)
.Where(x =>
{
if (x.FieldType == typeof(object))
{
// object. coannot serialize
return false;
}
if (x.IsLiteral && !x.IsInitOnly)
{
// const

View File

@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UniJSON;
namespace UniGLTF
@@ -22,6 +24,17 @@ namespace UniGLTF
[ItemJsonSchema(Minimum = 0)]
public int texCoord;
static IEnumerable<float> DeserializeFloat2(ListTreeNode<JsonValue> json)
{
if (json.Value.ValueType == ValueNodeType.Array)
{
foreach (var a in json.ArrayItems())
{
yield return a.GetSingle();
}
}
}
static glTF_KHR_texture_transform Deserialize(ListTreeNode<JsonValue> json)
{
var t = new glTF_KHR_texture_transform();
@@ -34,22 +47,25 @@ namespace UniGLTF
switch (key)
{
case nameof(offset):
throw new NotImplementedException();
t.offset = DeserializeFloat2(kv.Value).ToArray();
break;
case nameof(rotation):
throw new NotImplementedException();
t.rotation = kv.Value.GetSingle();
break;
case nameof(scale):
throw new NotImplementedException();
t.scale = DeserializeFloat2(kv.Value).ToArray();
break;
case nameof(texCoord):
throw new NotImplementedException();
t.texCoord = kv.Value.GetInt32();
break;
default:
throw new NotImplementedException();
}
}
}
return t;