Skip to content

Commit

Permalink
default の SpringboneRuntime の条件見直し
Browse files Browse the repository at this point in the history
  • Loading branch information
ousttrue committed Oct 25, 2024
1 parent 135ec7a commit 9c93339
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 31 deletions.
39 changes: 10 additions & 29 deletions Assets/VRM10/Runtime/Components/Vrm10Instance/Vrm10Instance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,43 +115,24 @@ public UniHumanoid.Humanoid Humanoid
}
}

/// <summary>
/// SpringboneRuntime が無かった時にデフォルトの runtime を作成する
///
/// - Importer に SpringboneRuntime 引数が無かった時
/// - Scene 配置 model のスタートアップ
///
/// </summary>
/// <param name="root"></param>
/// <returns></returns>
internal static IVrm10SpringBoneRuntime MakeSpringboneRuntime(GameObject root)
internal Vrm10Runtime MakeRuntime(bool useControlRig)
{
if (root != null)
if (m_springBoneRuntime == null)
{
var provider = root.GetComponent<IVrm10SpringBoneRuntimeProvider>();
// springbone が無い => シーン配置モデルが play されたと見做す
var provider = GetComponent<IVrm10SpringBoneRuntimeProvider>();
if (provider != null)
{
// 明示的カスタマイズ
return provider.CreateSpringBoneRuntime();
m_springBoneRuntime = provider.CreateSpringBoneRuntime();
}
}

if (Application.isEditor)
{
// note: test, timeline などで Singleton(DontDestroyOnLoad) が都合が悪い
return new Vrm10FastSpringboneRuntimeStandalone();
}

// default
return new Vrm10FastSpringboneRuntime();
}
if (m_springBoneRuntime == null)
{
// シーン配置 play のデフォルトは singletone ではない方
m_springBoneRuntime = new Vrm10FastSpringboneRuntimeStandalone();
}

internal Vrm10Runtime MakeRuntime(bool useControlRig)
{
if (m_springBoneRuntime == null)
{
// springbone が無い => シーン配置モデルが play されたと見做す
m_springBoneRuntime = MakeSpringboneRuntime(gameObject);
m_springBoneRuntime.InitializeAsync(this, new ImmediateCaller());
}
else
Expand Down
11 changes: 9 additions & 2 deletions Assets/VRM10/Runtime/IO/Vrm10Importer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,15 @@ public Vrm10Importer(
}
else
{
// default の SpringboneRuntime を作成する
springboneRuntime = Vrm10Instance.MakeSpringboneRuntime(null);
if (!Application.isPlaying)
{
// play中でない。test 対策
springboneRuntime = new Vrm10FastSpringboneRuntimeStandalone();
}
else
{
springboneRuntime = new Vrm10FastSpringboneRuntime();
}
}
}
m_springboneRuntime = springboneRuntime;
Expand Down

0 comments on commit 9c93339

Please sign in to comment.