Skip to content

Commit

Permalink
Fix UnassignedReferenceException when rootTransform of PhysBone i…
Browse files Browse the repository at this point in the history
…s none
  • Loading branch information
yokra9 committed Jan 18, 2023
1 parent b8b036b commit f0332cd
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions Editor/VRoidAvatar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class VRoidAvatar
//// Expressions
public bool expressionsMenu = true;
public bool expressionParameters = true;

// Pipeline Manager
public bool blueprintId = true;

Expand Down Expand Up @@ -178,8 +178,8 @@ public void CopyToTarget(GameObject targetObject)
{
errors.Add("コピー先アバターにVRCAvatarDescriptorコンポーネントがないためコピーできませんでした。\n VRCAvatarDescriptor配下の項目のチェックを外すか、コピー先アバターにコンポーネントを追加してください");
}
if(ShouldCopyVRCAvatarDescripter() && sourceAvatarDescriptor != null && targetAvatarDescriptor != null)

if (ShouldCopyVRCAvatarDescripter() && sourceAvatarDescriptor != null && targetAvatarDescriptor != null)
{
if (viewPosition)
{
Expand Down Expand Up @@ -374,13 +374,16 @@ public void CopyToTarget(GameObject targetObject)
{
if (avatarMode == 0)
{
if (checkExclutionPhysBoneContain(phy.rootTransform.name))
{
continue;
}
else if (!checkPhysBoneContain(phy.rootTransform.name) && !physBones_other)
if (phy.rootTransform != null)
{
continue;
if (checkExclutionPhysBoneContain(phy.rootTransform.name))
{
continue;
}
else if (!checkPhysBoneContain(phy.rootTransform.name) && !physBones_other)
{
continue;
}
}
}
ComponentUtility.CopyComponent(phy);
Expand All @@ -390,7 +393,10 @@ public void CopyToTarget(GameObject targetObject)
VRCPhysBone[] p = targetObj.GetComponents<VRCPhysBone>();
VRCPhysBone newPhysBone = p[p.Length - 1];

newPhysBone.rootTransform = targetObject.transform.Find(newPhysBone.rootTransform.gameObject.GetFullPath()).gameObject.transform;
if (phy.rootTransform != null)
{
newPhysBone.rootTransform = targetObject.transform.Find(newPhysBone.rootTransform.gameObject.GetFullPath()).gameObject.transform;
}

List<VRCPhysBoneColliderBase> new_coliders = new List<VRCPhysBoneColliderBase>();
foreach (var tarcol in newPhysBone.colliders)
Expand Down

0 comments on commit f0332cd

Please sign in to comment.