mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-10-02 15:53:30 -05:00
ExtensionSerialization
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 827d441621713194c88a8c94b7b1c2f0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user