This commit is contained in:
ousttrue
2021-04-12 21:05:15 +09:00
parent 6977424196
commit 78cda85380

View File

@@ -3,6 +3,7 @@ using System;
using UnityEditor;
using UnityEngine;
using MeshUtility.M17N;
using System.Reflection;
namespace VRM
{
@@ -109,6 +110,24 @@ namespace VRM
m_divideVertexBuffer = new CheckBoxProp(serializedObject.FindProperty(nameof(VRMExportSettings.DivideVertexBuffer)), Options.DIVIDE_VERTEX_BUFFER);
}
static bool TrySampleBindPose(GameObject go)
{
// https://forum.unity.com/threads/mesh-bindposes.383752/
var type = Type.GetType("UnityEditor.AvatarSetupTool, UnityEditor");
if (type != null)
{
var info = type.GetMethod("SampleBindPose", BindingFlags.Static | BindingFlags.Public);
if (info != null)
{
var clone = GameObject.Instantiate(go);
info.Invoke(null, new object[] { clone });
return true;
}
}
return false;
}
public override void OnInspectorGUI()
{
GUILayout.Space(20);
@@ -126,11 +145,26 @@ namespace VRM
}
if (GUILayout.Button(Options.DO_TPOSE.Msg()))
{
if (settings.Root)
if (settings.Root != null)
{
// fallback
VRMBoneNormalizer.EnforceTPose(settings.Root);
}
}
if (GUILayout.Button(Options.DO_TPOSE.Msg() + "(internal)"))
{
if (settings.Root != null)
{
if (TrySampleBindPose(settings.Root))
{
// done
}
else
{
Debug.LogWarning("not found");
}
}
}
GUI.enabled = backup;
GUILayout.Space(20);