From 0f7d2e8f7c9d53daebcfd80cdce6c72e5bcf6019 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 20 Oct 2022 15:01:09 +0900 Subject: [PATCH] rename, namespace --- .../{MigrationApi.cs => Migrator.cs} | 2 +- ...{MigrationApi.cs.meta => Migrator.cs.meta} | 2 +- Assets/VRM10/Runtime/Migration/Vrm0Meta.cs | 2 +- .../MigrateExporter/MigrateExporter.cs | 82 +++++++++---------- .../MigrateExporter/README.md | 7 +- 5 files changed, 49 insertions(+), 46 deletions(-) rename Assets/VRM10/Runtime/Migration/{MigrationApi.cs => Migrator.cs} (93%) rename Assets/VRM10/Runtime/Migration/{MigrationApi.cs.meta => Migrator.cs.meta} (83%) diff --git a/Assets/VRM10/Runtime/Migration/MigrationApi.cs b/Assets/VRM10/Runtime/Migration/Migrator.cs similarity index 93% rename from Assets/VRM10/Runtime/Migration/MigrationApi.cs rename to Assets/VRM10/Runtime/Migration/Migrator.cs index 170e9a377..7eeed73ce 100644 --- a/Assets/VRM10/Runtime/Migration/MigrationApi.cs +++ b/Assets/VRM10/Runtime/Migration/Migrator.cs @@ -2,7 +2,7 @@ using System; namespace UniVRM10 { - public static class MigrationApi + public static class Migrator { /// /// マイグレーションの公開API diff --git a/Assets/VRM10/Runtime/Migration/MigrationApi.cs.meta b/Assets/VRM10/Runtime/Migration/Migrator.cs.meta similarity index 83% rename from Assets/VRM10/Runtime/Migration/MigrationApi.cs.meta rename to Assets/VRM10/Runtime/Migration/Migrator.cs.meta index 96948be1d..ddc6160ae 100644 --- a/Assets/VRM10/Runtime/Migration/MigrationApi.cs.meta +++ b/Assets/VRM10/Runtime/Migration/Migrator.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: be52b15d95590934b93e744181762dfe +guid: db393ac50cf8db343a6cf58ed69687f6 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/VRM10/Runtime/Migration/Vrm0Meta.cs b/Assets/VRM10/Runtime/Migration/Vrm0Meta.cs index b3e9dcb22..8cc99fbee 100644 --- a/Assets/VRM10/Runtime/Migration/Vrm0Meta.cs +++ b/Assets/VRM10/Runtime/Migration/Vrm0Meta.cs @@ -23,7 +23,7 @@ namespace UniVRM10.Migration Other } - public enum UssageLicense + public enum UsageLicense { Disallow, Allow, diff --git a/Assets/VRM_0x_and_10_Samples/MigrateExporter/MigrateExporter.cs b/Assets/VRM_0x_and_10_Samples/MigrateExporter/MigrateExporter.cs index d381f9d0d..c735d2dba 100644 --- a/Assets/VRM_0x_and_10_Samples/MigrateExporter/MigrateExporter.cs +++ b/Assets/VRM_0x_and_10_Samples/MigrateExporter/MigrateExporter.cs @@ -1,56 +1,56 @@ -using System.Collections; -using System.Collections.Generic; using System.IO; -using System.Linq; using UnityEngine; -[DisallowMultipleComponent] -public class MigrateExporter : MonoBehaviour +namespace UniVRM10.Sample { - [SerializeField] - UniVRM10.VRM10ObjectMeta _meta = new UniVRM10.VRM10ObjectMeta(); - - async void OnGUI() + [DisallowMultipleComponent] + public class MigrateExporter : MonoBehaviour { - // validate - foreach (var validation in _meta.Validate(null)) - { - GUILayout.Label("meta validation: " + validation.Message); - if (!validation.CanExport) - { - GUI.enabled = false; - } - } + [SerializeField] + UniVRM10.VRM10ObjectMeta _meta = new UniVRM10.VRM10ObjectMeta(); - if (GUILayout.Button("migrate")) + async void OnGUI() { - var path = UnityEditor.EditorUtility.OpenFilePanel("load vrm-0.x", null, "vrm"); - if (string.IsNullOrEmpty(path)) + // validate + foreach (var validation in _meta.Validate(null)) { - return; + GUILayout.Label("meta validation: " + validation.Message); + if (!validation.CanExport) + { + GUI.enabled = false; + } } - Debug.Log(path); - var bytes = File.ReadAllBytes(path); - - // load - var vrm0Instance = await VRM.VrmUtility.LoadBytesAsync(path, bytes); - - // export設定 - var exportConfig = new UniGLTF.GltfExportSettings + if (GUILayout.Button("migrate")) { - }; - // export vrm0 - var vrm0 = VRM.VRMExporter.Export(exportConfig, - vrm0Instance.gameObject, new VRMShaders.RuntimeTextureSerializer()); - var vrm0bytes = vrm0.ToGlbBytes(); + var path = UnityEditor.EditorUtility.OpenFilePanel("load vrm-0.x", null, "vrm"); + if (string.IsNullOrEmpty(path)) + { + return; + } - // migrate to vrm1 - var vrm1Bytes = UniVRM10.MigrationApi.Migrate(vrm0bytes, _meta); - var pathObj = VRMShaders.PathObject.FromFullPath(path); - var newPath = pathObj.Parent.Child(pathObj.Stem + ".10.vrm"); - newPath.WriteAllBytes(vrm1Bytes); - Debug.Log($"export to: {newPath}"); + Debug.Log(path); + var bytes = File.ReadAllBytes(path); + + // load + var vrm0Instance = await VRM.VrmUtility.LoadBytesAsync(path, bytes); + + // export設定 + var exportConfig = new UniGLTF.GltfExportSettings + { + }; + // export vrm0 + var vrm0 = VRM.VRMExporter.Export(exportConfig, + vrm0Instance.gameObject, new VRMShaders.RuntimeTextureSerializer()); + var vrm0bytes = vrm0.ToGlbBytes(); + + // migrate to vrm1 + var vrm1Bytes = UniVRM10.Migrator.Migrate(vrm0bytes, _meta); + var pathObj = VRMShaders.PathObject.FromFullPath(path); + var newPath = pathObj.Parent.Child(pathObj.Stem + ".10.vrm"); + newPath.WriteAllBytes(vrm1Bytes); + Debug.Log($"export to: {newPath}"); + } } } } diff --git a/Assets/VRM_0x_and_10_Samples/MigrateExporter/README.md b/Assets/VRM_0x_and_10_Samples/MigrateExporter/README.md index ca0648b31..9b7d67607 100644 --- a/Assets/VRM_0x_and_10_Samples/MigrateExporter/README.md +++ b/Assets/VRM_0x_and_10_Samples/MigrateExporter/README.md @@ -1,11 +1,11 @@ -# Migration +# MigrateExporter - for runtime - Convert export vrm0 model directly to vrm1 - input: vrm0 hierarchy + vrm1 meta - output: vrm1 binary -## detail +## Detail 最初に vrm0 モデルをエクスポートします。 このとき後で vrm1 化する前提で通常とは別の設定にします。 @@ -22,3 +22,6 @@ - https://github.com/vrm-c/glTF-Validator/pull/1 +## Caution + +プログラムの利用者が、入力に使う vrm0 のライセンスを管理できるようにしてください。