From a96e0b6267e9fd3a6a415661c8c5ae0a1fa202e8 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 2 Jul 2021 17:06:17 +0900 Subject: [PATCH] GenerateInfo --- Assets/VRM10/Editor/GeneratorMenu.cs | 72 +++++++++++++++++++--------- 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/Assets/VRM10/Editor/GeneratorMenu.cs b/Assets/VRM10/Editor/GeneratorMenu.cs index e39a678b3..66d3392e2 100644 --- a/Assets/VRM10/Editor/GeneratorMenu.cs +++ b/Assets/VRM10/Editor/GeneratorMenu.cs @@ -29,46 +29,74 @@ namespace UniVRM10 } #endif + struct GenerateInfo + { + public string JsonSchema; + public string FormatDir; + public string SerializerDir; + + public GenerateInfo(string jsonSchema, string formatDir, string serializerDir) + { + JsonSchema = jsonSchema; + FormatDir = formatDir; + SerializerDir = serializerDir; + } + } + static void Run(bool debug) { var projectRoot = new DirectoryInfo(Path.GetFullPath(Path.Combine(Application.dataPath, "../"))); var gltf = new FileInfo(Path.Combine(projectRoot.FullName, "glTF/specification/2.0/schema/glTF.schema.json")); - var args = new string[] + var args = new GenerateInfo[] { - // VRMC_vrm - "vrm-specification/specification/VRMC_vrm-1.0_draft/schema/VRMC_vrm.schema.json", - "Assets/VRM10/Runtime/Format/Vrm", // format - "Assets/VRM10/Runtime/Format/Vrm", // serializer // VRMC_hdr_emissiveMultiplier - "vrm-specification/specification/VRMC_materials_hdr_emissiveMultiplier-1.0_draft/schema/VRMC_materials_hdr_emissiveMultiplier.json", - "Assets/VRMShaders/VRM10/Format/Runtime/EmissiveMultiplier", // format - "Assets/VRM10/Runtime/Format/EmissiveMultiplier", // serializer + new GenerateInfo( + "vrm-specification/specification/VRMC_materials_hdr_emissiveMultiplier-1.0_draft/schema/VRMC_materials_hdr_emissiveMultiplier.json", + "Assets/VRMShaders/VRM10/Format/Runtime/EmissiveMultiplier", + "Assets/VRM10/Runtime/Format/EmissiveMultiplier" + ), + + // VRMC_vrm + new GenerateInfo( + "vrm-specification/specification/VRMC_vrm-1.0_draft/schema/VRMC_vrm.schema.json", + "Assets/VRM10/Runtime/Format/Vrm", + "Assets/VRM10/Runtime/Format/Vrm" + ), + // VRMC_materials_mtoon - "vrm-specification/specification/VRMC_materials_mtoon-1.0_draft/schema/VRMC_materials_mtoon.schema.json", - "Assets/VRMShaders/VRM10/Format/Runtime/MaterialsMToon", // format - "Assets/VRM10/Runtime/Format/MaterialsMToon", // serializer + new GenerateInfo( + "vrm-specification/specification/VRMC_materials_mtoon-1.0_draft/schema/VRMC_materials_mtoon.schema.json", + "Assets/VRMShaders/VRM10/Format/Runtime/MaterialsMToon", + "Assets/VRM10/Runtime/Format/MaterialsMToon" + ), + // VRMC_springBone - "vrm-specification/specification/VRMC_springBone-1.0_draft/schema/VRMC_springBone.schema.json", - "Assets/VRM10/Runtime/Format/SpringBone", // format - "Assets/VRM10/Runtime/Format/SpringBone", // serializer + new GenerateInfo( + "vrm-specification/specification/VRMC_springBone-1.0_draft/schema/VRMC_springBone.schema.json", + "Assets/VRM10/Runtime/Format/SpringBone", + "Assets/VRM10/Runtime/Format/SpringBone" + ), + // VRMC_node_constraint - "vrm-specification/specification/VRMC_node_constraint-1.0_draft/schema/VRMC_node_constraint.schema.json", - "Assets/VRM10/Runtime/Format/Constraints", // format - "Assets/VRM10/Runtime/Format/Constraints", // serializer + new GenerateInfo( + "vrm-specification/specification/VRMC_node_constraint-1.0_draft/schema/VRMC_node_constraint.schema.json", + "Assets/VRM10/Runtime/Format/Constraints", + "Assets/VRM10/Runtime/Format/Constraints" + ), }; - for (int i = 0; i < args.Length; i += 3) + foreach (var arg in args) { - var extensionSchemaPath = new FileInfo(Path.Combine(projectRoot.FullName, args[i])); + var extensionSchemaPath = new FileInfo(Path.Combine(projectRoot.FullName, arg.JsonSchema)); var parser = new UniGLTF.JsonSchema.JsonSchemaParser(gltf.Directory, extensionSchemaPath.Directory); var extensionSchema = parser.Load(extensionSchemaPath, ""); - var formatDst = new DirectoryInfo(Path.Combine(projectRoot.FullName, args[i + 1])); + var formatDst = new DirectoryInfo(Path.Combine(projectRoot.FullName, arg.FormatDir)); Debug.Log($"Format.g Dir: {formatDst}"); - - var serializerDst = new DirectoryInfo(Path.Combine(projectRoot.FullName, args[i + 2])); + + var serializerDst = new DirectoryInfo(Path.Combine(projectRoot.FullName, arg.SerializerDir)); Debug.Log($"Serializer/Deserializer.g Dir: {serializerDst}"); if (debug)