mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-20 05:10:08 +08:00
chore: reduce # of GetComponentsInChildren
This commit is contained in:
parent
664a6c3081
commit
42d83304ab
@ -91,22 +91,6 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var c in avatarGameObject.transform.GetComponentsInChildren<AimConstraint>(true))
|
|
||||||
{
|
|
||||||
if (!AddedConstraints.Contains(c))
|
|
||||||
{
|
|
||||||
FixupAimConstraint(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var c in avatarGameObject.transform.GetComponentsInChildren<LookAtConstraint>(true))
|
|
||||||
{
|
|
||||||
if (!AddedConstraints.Contains(c))
|
|
||||||
{
|
|
||||||
FixupLookAtConstraint(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var bone in ToDelete) UnityEngine.Object.DestroyImmediate(bone);
|
foreach (var bone in ToDelete) UnityEngine.Object.DestroyImmediate(bone);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -121,16 +105,16 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
source.sourceTransform = MapConstraintSource(source.sourceTransform);
|
source.sourceTransform = MapConstraintSource(source.sourceTransform);
|
||||||
constraint.SetSource(i, source);
|
constraint.SetSource(i, source);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void FixupAimConstraint(AimConstraint constraint)
|
if (constraint is AimConstraint aimConstraint)
|
||||||
{
|
{
|
||||||
constraint.worldUpObject = MapConstraintSource(constraint.worldUpObject);
|
aimConstraint.worldUpObject = MapConstraintSource(aimConstraint.worldUpObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FixupLookAtConstraint(LookAtConstraint constraint)
|
if (constraint is LookAtConstraint lookAtConstraint)
|
||||||
{
|
{
|
||||||
constraint.worldUpObject = MapConstraintSource(constraint.worldUpObject);
|
lookAtConstraint.worldUpObject = MapConstraintSource(lookAtConstraint.worldUpObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Transform MapConstraintSource(Transform transform)
|
private Transform MapConstraintSource(Transform transform)
|
||||||
|
Loading…
Reference in New Issue
Block a user