UniVRM/Assets/VRM/Editor/Format/VRMHumanoidNormalizerMenu.cs
ousttrue be20563059 GetComponent を置き換え。
TryGetComponent
GetComponentOrThrow(拡張関数)
GetComponentOrNull(拡張関数)

sample と test は据え置き
2024-07-24 22:09:30 +09:00

54 lines
1.1 KiB
C#

using System.Linq;
using UnityEditor;
using UnityEngine;
using UniGLTF;
namespace VRM
{
public static class VRMHumanoidNormalizerMenu
{
public const string MENU_NAME = "VRM 0.x Freeze T-Pose";
public static bool NormalizeValidation()
{
var root = Selection.activeObject as GameObject;
if (root == null)
{
return false;
}
if (root.TryGetComponent<Animator>(out var animator))
{
var avatar = animator.avatar;
if (avatar == null)
{
return false;
}
if (!avatar.isValid)
{
return false;
}
if (!avatar.isHuman)
{
return false;
}
return true;
}
else
{
return false;
}
}
public static void Normalize()
{
var go = Selection.activeObject as GameObject;
VRMBoneNormalizer.Execute(go, true);
}
}
}