Skip to content

Commit

Permalink
Merge pull request #529 from ousttrue/fix/fix_export_meta
Browse files Browse the repository at this point in the history
初回Export時のmeta受け渡し方法を修正
  • Loading branch information
ousttrue authored Aug 28, 2020
2 parents 0bcae53 + 567dd39 commit 459b9cb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
18 changes: 15 additions & 3 deletions Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public static class VRMEditorExporter
/// </summary>
/// <param name="path">出力先</param>
/// <param name="settings">エクスポート設定</param>
public static void Export(string path, GameObject exportRoot, VRMExportSettings settings)
public static void Export(string path, GameObject exportRoot, VRMMetaObject meta, VRMExportSettings settings)
{
List<GameObject> destroy = new List<GameObject>();
try
{
Export(path, exportRoot, settings, destroy);
Export(path, exportRoot, meta, settings, destroy);
}
finally
{
Expand Down Expand Up @@ -136,14 +136,26 @@ static void ForceUniqueName(Transform transform, Dictionary<string, int> nameCou
/// <param name="path"></param>
/// <param name="settings"></param>
/// <param name="destroy">作業が終わったらDestoryするべき一時オブジェクト</param>
static void Export(string path, GameObject exportRoot, VRMExportSettings settings, List<GameObject> destroy)
static void Export(string path, GameObject exportRoot, VRMMetaObject meta, VRMExportSettings settings, List<GameObject> destroy)
{
var target = exportRoot;

// 常にコピーする。シーンを変化させない
target = GameObject.Instantiate(target);
destroy.Add(target);

var metaBehaviour = target.GetComponent<VRMMeta>();
if (metaBehaviour == null)
{
metaBehaviour = target.AddComponent<VRMMeta>();
metaBehaviour.Meta = meta;
}
if (metaBehaviour.Meta == null)
{
// 来ないはず
throw new Exception("meta required");
}

{
// copy元
var animator = exportRoot.GetComponent<Animator>();
Expand Down
15 changes: 1 addition & 14 deletions Assets/VRM/UniVRM/Editor/Format/VRMExporterWizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -695,20 +695,7 @@ void OnWizardCreate()
m_lastExportDir = Path.GetDirectoryName(path).Replace("\\", "/");

// export
if (Meta == null)
{
var metaB = ExportRoot.GetComponent<VRMMeta>();
if (metaB == null)
{
metaB = ExportRoot.AddComponent<VRMMeta>();
}
metaB.Meta = m_tmpMeta;
}
VRMEditorExporter.Export(path, ExportRoot, m_settings);
if (Meta == null)
{
UnityEngine.GameObject.DestroyImmediate(ExportRoot.GetComponent<VRMMeta>());
}
VRMEditorExporter.Export(path, ExportRoot, Meta != null ? Meta : m_tmpMeta, m_settings);
}

void OnWizardUpdate()
Expand Down

0 comments on commit 459b9cb

Please sign in to comment.