mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-03-28 13:24:58 -05:00
56 lines
1.3 KiB
C#
56 lines
1.3 KiB
C#
using System.Linq;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using UniGLTF;
|
|
|
|
|
|
namespace VRM
|
|
{
|
|
public static class VRMHumanoidNormalizerMenu
|
|
{
|
|
const string MENU_KEY = VRMVersion.MENU + "/Freeze T-Pose";
|
|
[MenuItem(MENU_KEY, true, 1)]
|
|
private static bool ExportValidate()
|
|
{
|
|
var root = Selection.activeObject as GameObject;
|
|
if (root == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var animator = root.GetComponent<Animator>();
|
|
if (animator == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var avatar = animator.avatar;
|
|
if (avatar == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (!avatar.isValid)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (!avatar.isHuman)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
[MenuItem(MENU_KEY, false, 1)]
|
|
private static void ExportFromMenu()
|
|
{
|
|
var go = Selection.activeObject as GameObject;
|
|
|
|
// BoneNormalizer.Execute はコピーを正規化する。UNDO無用
|
|
Selection.activeGameObject = VRMBoneNormalizer.Execute(go, true);
|
|
}
|
|
}
|
|
}
|