rename, namespace

This commit is contained in:
ousttrue 2022-10-20 15:01:09 +09:00
parent cb906d66cf
commit 0f7d2e8f7c
5 changed files with 49 additions and 46 deletions

View File

@ -2,7 +2,7 @@ using System;
namespace UniVRM10
{
public static class MigrationApi
public static class Migrator
{
/// <summary>
/// マイグレーションの公開API

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: be52b15d95590934b93e744181762dfe
guid: db393ac50cf8db343a6cf58ed69687f6
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -23,7 +23,7 @@ namespace UniVRM10.Migration
Other
}
public enum UssageLicense
public enum UsageLicense
{
Disallow,
Allow,

View File

@ -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}");
}
}
}
}

View File

@ -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 のライセンスを管理できるようにしてください。