Skip to content

Commit

Permalink
Merge pull request #2232 from ousttrue/fix/firstperson_null_check
Browse files Browse the repository at this point in the history
VRMFirstPerson.CopyTo skip null
  • Loading branch information
ousttrue committed Jan 26, 2024
2 parents 12736e2 + 29c6ad9 commit 226df16
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Assets/VRM/Runtime/FirstPerson/VRMFirstPerson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,22 @@ public void CopyTo(GameObject _dst, Dictionary<Transform, Transform> map)
var dst = _dst.AddComponent<VRMFirstPerson>();
dst.FirstPersonBone = map[FirstPersonBone];
dst.FirstPersonOffset = FirstPersonOffset;
dst.Renderers = Renderers.Select(x =>
dst.Renderers = Renderers
.Where(x =>
{
if (x.Renderer == null || x.Renderer.transform == null)
{
Debug.LogWarning("[VRMFirstPerson] Renderer is null", this);
return false;
}
if (!map.ContainsKey(x.Renderer.transform))
{
Debug.LogWarning("[VRMFirstPerson] Cannot copy. Not found ?", this);
return false;
}
return true;
})
.Select(x =>
{
var mapped = map[x.Renderer.transform];
var renderer = mapped.GetComponent<Renderer>();
Expand Down

0 comments on commit 226df16

Please sign in to comment.