mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-01 07:15:13 -05:00
Fix RebuildHumanAvatar so it works in play mode
This commit is contained in:
parent
3b99078d26
commit
3727eee600
|
|
@ -55,7 +55,10 @@ namespace UniHumanoid
|
|||
/// HumanBone のマッピングを流用して、新たな Avatar を作り直す。
|
||||
/// 古い Avatar は破棄する。
|
||||
/// </summary>
|
||||
public static void RebuildHumanAvatar(Animator animator)
|
||||
/// <remarks>
|
||||
/// This method runs asynchronously only in play mode.
|
||||
/// </remarks>
|
||||
public static async Awaitable RebuildHumanAvatar(Animator animator)
|
||||
{
|
||||
if (animator == null)
|
||||
{
|
||||
|
|
@ -77,6 +80,9 @@ namespace UniHumanoid
|
|||
if (Application.isPlaying)
|
||||
{
|
||||
GameObject.Destroy(animator);
|
||||
|
||||
// Else, the following AddComponent call will fail.
|
||||
await Awaitable.NextFrameAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,7 +53,10 @@ namespace VRM
|
|||
/// <param name="go">対象モデルのルート</param>
|
||||
/// <param name="forceTPose">強制的にT-Pose化するか</param>
|
||||
/// <param name="useCurrentBlendShapeWeight">BlendShape の現状をbakeするか</param>
|
||||
public static void Execute(GameObject go, bool forceTPose, bool useCurrentBlendShapeWeight)
|
||||
/// <remarks>
|
||||
/// This method runs asynchronously only in play mode.
|
||||
/// </remarks>
|
||||
public static async Awaitable Execute(GameObject go, bool forceTPose, bool useCurrentBlendShapeWeight)
|
||||
{
|
||||
if (forceTPose)
|
||||
{
|
||||
|
|
@ -83,7 +86,7 @@ namespace VRM
|
|||
// 回転とスケールが除去された新しいヒエラルキーからAvatarを作る
|
||||
if (go.TryGetComponent<Animator>(out var animator))
|
||||
{
|
||||
HumanoidLoader.RebuildHumanAvatar(animator);
|
||||
await HumanoidLoader.RebuildHumanAvatar(animator);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user