mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-01 20:25:07 +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);
|
||||
|
||||
return true;
|
||||
@ -121,16 +105,16 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
source.sourceTransform = MapConstraintSource(source.sourceTransform);
|
||||
constraint.SetSource(i, source);
|
||||
}
|
||||
}
|
||||
|
||||
private void FixupAimConstraint(AimConstraint constraint)
|
||||
{
|
||||
constraint.worldUpObject = MapConstraintSource(constraint.worldUpObject);
|
||||
}
|
||||
if (constraint is AimConstraint aimConstraint)
|
||||
{
|
||||
aimConstraint.worldUpObject = MapConstraintSource(aimConstraint.worldUpObject);
|
||||
}
|
||||
|
||||
private void FixupLookAtConstraint(LookAtConstraint constraint)
|
||||
{
|
||||
constraint.worldUpObject = MapConstraintSource(constraint.worldUpObject);
|
||||
if (constraint is LookAtConstraint lookAtConstraint)
|
||||
{
|
||||
lookAtConstraint.worldUpObject = MapConstraintSource(lookAtConstraint.worldUpObject);
|
||||
}
|
||||
}
|
||||
|
||||
private Transform MapConstraintSource(Transform transform)
|
||||
|
Loading…
Reference in New Issue
Block a user