mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-04-04 19:49:02 +08:00
Make sure the VRC constraint only applies on VRChat avatars
This commit is contained in:
parent
7a1637f4ce
commit
be780dceee
@ -87,30 +87,37 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
obj.transform.localScale = Vector3.one;
|
||||
|
||||
#if MA_VRCSDK3_AVATARS_3_7_0_OR_NEWER
|
||||
var constraint = obj.AddComponent(
|
||||
System.Type.GetType("VRC.SDK3.Dynamics.Constraint.Components.VRCParentConstraint, VRC.SDK3.Dynamics.Constraint")
|
||||
) as VRC.Dynamics.ManagedTypes.VRCParentConstraintBase;
|
||||
constraint.IsActive = true;
|
||||
constraint.Locked = true;
|
||||
constraint.AffectsPositionX = true;
|
||||
constraint.AffectsPositionY = true;
|
||||
constraint.AffectsPositionZ = true;
|
||||
constraint.AffectsRotationX = true;
|
||||
constraint.AffectsRotationY = true;
|
||||
constraint.AffectsRotationZ = true;
|
||||
constraint.FreezeToWorld = true;
|
||||
#else
|
||||
var constraint = obj.AddComponent<ParentConstraint>();
|
||||
constraint.AddSource(new ConstraintSource()
|
||||
var isVrcAvatar = avatarRoot.TryGetComponent(out VRC.SDKBase.VRC_AvatarDescriptor _);
|
||||
|
||||
if (isVrcAvatar)
|
||||
{
|
||||
weight = 1.0f,
|
||||
sourceTransform = fixedGameObject.transform,
|
||||
});
|
||||
constraint.constraintActive = true;
|
||||
constraint.locked = true;
|
||||
constraint.rotationOffsets = new[] {Vector3.zero};
|
||||
constraint.translationOffsets = new[] {Vector3.zero};
|
||||
var constraint = obj.AddComponent(
|
||||
System.Type.GetType("VRC.SDK3.Dynamics.Constraint.Components.VRCParentConstraint, VRC.SDK3.Dynamics.Constraint")
|
||||
) as VRC.Dynamics.ManagedTypes.VRCParentConstraintBase;
|
||||
constraint.IsActive = true;
|
||||
constraint.Locked = true;
|
||||
constraint.AffectsPositionX = true;
|
||||
constraint.AffectsPositionY = true;
|
||||
constraint.AffectsPositionZ = true;
|
||||
constraint.AffectsRotationX = true;
|
||||
constraint.AffectsRotationY = true;
|
||||
constraint.AffectsRotationZ = true;
|
||||
constraint.FreezeToWorld = true;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
var constraint = obj.AddComponent<ParentConstraint>();
|
||||
constraint.AddSource(new ConstraintSource()
|
||||
{
|
||||
weight = 1.0f,
|
||||
sourceTransform = fixedGameObject.transform,
|
||||
});
|
||||
constraint.constraintActive = true;
|
||||
constraint.locked = true;
|
||||
constraint.rotationOffsets = new[] {Vector3.zero};
|
||||
constraint.translationOffsets = new[] {Vector3.zero};
|
||||
}
|
||||
|
||||
_proxy = obj.transform;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user