mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-20 01:37:59 -05:00
SpringboneRuntime が null だと NullReference Exception
SpringboneRuntime が null になるのは、scene 配置 play の時だけ。
This commit is contained in:
parent
7dc74ea15c
commit
135ec7a0da
|
|
@ -115,31 +115,49 @@ namespace UniVRM10
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SpringboneRuntime が無かった時にデフォルトの runtime を作成する
|
||||
///
|
||||
/// - Importer に SpringboneRuntime 引数が無かった時
|
||||
/// - Scene 配置 model のスタートアップ
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="root"></param>
|
||||
/// <returns></returns>
|
||||
internal static IVrm10SpringBoneRuntime MakeSpringboneRuntime(GameObject root)
|
||||
{
|
||||
if (root != null)
|
||||
{
|
||||
var provider = root.GetComponent<IVrm10SpringBoneRuntimeProvider>();
|
||||
if (provider != null)
|
||||
{
|
||||
// 明示的カスタマイズ
|
||||
return provider.CreateSpringBoneRuntime();
|
||||
}
|
||||
}
|
||||
|
||||
if (Application.isEditor)
|
||||
{
|
||||
// note: test, timeline などで Singleton(DontDestroyOnLoad) が都合が悪い
|
||||
return new Vrm10FastSpringboneRuntimeStandalone();
|
||||
}
|
||||
|
||||
// default
|
||||
return new Vrm10FastSpringboneRuntime();
|
||||
}
|
||||
|
||||
internal Vrm10Runtime MakeRuntime(bool useControlRig)
|
||||
{
|
||||
if (m_springBoneRuntime == null)
|
||||
{
|
||||
// シーン配置モデルが play された
|
||||
var provider = GetComponent<IVrm10SpringBoneRuntimeProvider>();
|
||||
if (provider != null)
|
||||
{
|
||||
// 明示的カスタマイズ
|
||||
m_springBoneRuntime = provider.CreateSpringBoneRuntime();
|
||||
}
|
||||
else
|
||||
{
|
||||
// deafult に fallback
|
||||
if (Application.isEditor)
|
||||
{
|
||||
m_springBoneRuntime = new Vrm10FastSpringboneRuntimeStandalone();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_springBoneRuntime = new Vrm10FastSpringboneRuntime();
|
||||
}
|
||||
}
|
||||
// springbone が無い => シーン配置モデルが play されたと見做す
|
||||
m_springBoneRuntime = MakeSpringboneRuntime(gameObject);
|
||||
m_springBoneRuntime.InitializeAsync(this, new ImmediateCaller());
|
||||
}
|
||||
else
|
||||
{
|
||||
// importer 内で InitializeAsync が呼び出し済み
|
||||
}
|
||||
return new Vrm10Runtime(this, useControlRig, m_springBoneRuntime);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,24 +54,20 @@ namespace UniVRM10
|
|||
m_externalMap = new Dictionary<SubAssetKey, UnityEngine.Object>();
|
||||
}
|
||||
|
||||
m_springboneRuntime = MakeDefaultRuntime(springboneRuntime, isAssetImport);
|
||||
}
|
||||
|
||||
static IVrm10SpringBoneRuntime MakeDefaultRuntime(IVrm10SpringBoneRuntime runtime, bool isAssetImport)
|
||||
{
|
||||
if (runtime != null)
|
||||
if (springboneRuntime == null)
|
||||
{
|
||||
return runtime;
|
||||
if (isAssetImport)
|
||||
{
|
||||
// 何もしない dummy
|
||||
springboneRuntime = new Vrm10NopSpringboneRuntime();
|
||||
}
|
||||
else
|
||||
{
|
||||
// default の SpringboneRuntime を作成する
|
||||
springboneRuntime = Vrm10Instance.MakeSpringboneRuntime(null);
|
||||
}
|
||||
}
|
||||
|
||||
if (isAssetImport)
|
||||
{
|
||||
// 何もしない dummy
|
||||
return new Vrm10NopSpringboneRuntime();
|
||||
}
|
||||
|
||||
// Vrm10Instance.MakeRuntime に移譲
|
||||
return null;
|
||||
m_springboneRuntime = springboneRuntime;
|
||||
}
|
||||
|
||||
static void AssignHumanoid(List<VrmLib.Node> nodes, UniGLTF.Extensions.VRMC_vrm.HumanBone humanBone, VrmLib.HumanoidBones key)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user