mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-09 12:11:35 -05:00
VRMDeserializerGenerator
This commit is contained in:
parent
913dd97554
commit
8a959fc88a
|
|
@ -22,7 +22,7 @@ namespace UniGLTF
|
|||
/// <summary>
|
||||
/// AOT向けにデシリアライザを生成する
|
||||
/// </summary>
|
||||
[MenuItem(VRM.VRMVersion.MENU + "/Generate Deserializer")]
|
||||
[MenuItem(VRM.VRMVersion.MENU + "/GLTF: Generate Deserializer")]
|
||||
static void GenerateSerializer()
|
||||
{
|
||||
var info = new ObjectSerialization(typeof(glTF), "gltf");
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -6,7 +6,8 @@
|
|||
"UniHumanoid",
|
||||
"MeshUtility",
|
||||
"MeshUtility.Editor",
|
||||
"UniUnlit"
|
||||
"UniUnlit",
|
||||
"UniGLTF.Editor"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [
|
||||
|
|
|
|||
61
Assets/VRM/UniVRM/Editor/VRMDeserializerGenerator.cs
Normal file
61
Assets/VRM/UniVRM/Editor/VRMDeserializerGenerator.cs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
public static class DeserializerGenerator
|
||||
{
|
||||
public const BindingFlags FIELD_FLAGS = BindingFlags.Instance | BindingFlags.Public;
|
||||
|
||||
static string OutPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(UnityEngine.Application.dataPath,
|
||||
"VRM/UniVRM/Scripts/Format/VRMDeserializer.g.cs");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AOT向けにデシリアライザを生成する
|
||||
/// </summary>
|
||||
[MenuItem(VRM.VRMVersion.MENU + "/VRM: Generate Deserializer")]
|
||||
static void GenerateSerializer()
|
||||
{
|
||||
var info = new UniGLTF.ObjectSerialization(typeof(glTF_VRM_extensions), "vrm");
|
||||
Debug.Log(info);
|
||||
|
||||
using (var s = File.Open(OutPath, FileMode.Create))
|
||||
using (var w = new StreamWriter(s, Encoding.UTF8))
|
||||
{
|
||||
// header
|
||||
w.Write(@"
|
||||
using UniJSON;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using VRM;
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRM {
|
||||
|
||||
public static class VrmDeserializer
|
||||
{
|
||||
|
||||
");
|
||||
|
||||
info.GenerateDeserializer(w, "Deserialize");
|
||||
|
||||
// footer
|
||||
w.Write(@"
|
||||
} // VrmfDeserializer
|
||||
} // VRM
|
||||
");
|
||||
|
||||
Debug.LogFormat("write: {0}", OutPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/VRM/UniVRM/Editor/VRMDeserializerGenerator.cs.meta
Normal file
11
Assets/VRM/UniVRM/Editor/VRMDeserializerGenerator.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fccecb79adf40a948b2c218b4e7703b3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1099
Assets/VRM/UniVRM/Scripts/Format/VRMDeserializer.g.cs
Normal file
1099
Assets/VRM/UniVRM/Scripts/Format/VRMDeserializer.g.cs
Normal file
File diff suppressed because it is too large
Load Diff
11
Assets/VRM/UniVRM/Scripts/Format/VRMDeserializer.g.cs.meta
Normal file
11
Assets/VRM/UniVRM/Scripts/Format/VRMDeserializer.g.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7d3f5617d4d8fd74494cab1e56d6b001
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -5,6 +5,7 @@ using UniGLTF;
|
|||
using UnityEngine;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using UniJSON;
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
|
|
@ -13,13 +14,7 @@ namespace VRM
|
|||
const string HUMANOID_KEY = "humanoid";
|
||||
const string MATERIAL_KEY = "materialProperties";
|
||||
|
||||
public VRM.glTF_VRM_extensions VRM
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
public VRM.glTF_VRM_extensions VRM { get; private set; }
|
||||
|
||||
public VRMImporterContext()
|
||||
{
|
||||
|
|
@ -42,7 +37,25 @@ namespace VRM
|
|||
|
||||
public override void ParseJson(string json, IStorage storage)
|
||||
{
|
||||
// parse GLTF part(core + unlit, textureTransform, targetNames)
|
||||
base.ParseJson(json, storage);
|
||||
|
||||
// parse VRM part
|
||||
if (GLTF.extensions != null && GLTF.extensions is ListTreeNode<JsonValue> vrmJson)
|
||||
{
|
||||
if (vrmJson.Value.ValueType == ValueNodeType.Object)
|
||||
{
|
||||
foreach (var kv in vrmJson.ObjectItems())
|
||||
{
|
||||
if (kv.Key.GetString() == "VRM")
|
||||
{
|
||||
VRM = VrmDeserializer.Deserialize(kv.Value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetMaterialImporter(new VRMMaterialImporter(this, glTF_VRM_Material.Parse(Json)));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user