Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UnassignedReferenceException when rootTransform of PhysBone is none #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Editor/VRoidAvatar.cs
Original file line number Diff line number Diff line change
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 @@ -372,7 +372,7 @@ public void CopyToTarget(GameObject targetObject)
physBones = cloneGameObject.GetComponentsInChildren<VRCPhysBone>();
foreach (var phy in physBones)
{
if (avatarMode == 0)
if (avatarMode == 0 && phy.rootTransform != null)
{
if (checkExclutionPhysBoneContain(phy.rootTransform.name))
{
Expand All @@ -390,7 +390,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