From 7a1637f4ce19cf647a6e12a457931305668c6eac Mon Sep 17 00:00:00 2001 From: JLChnToZ <jeremylam619@gmail.com> Date: Wed, 30 Oct 2024 22:57:21 +0800 Subject: [PATCH] Use VRCParentConstraint instead of constraint hack for world fixed objects when available --- Editor/WorldFixedObjectProcessor.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Editor/WorldFixedObjectProcessor.cs b/Editor/WorldFixedObjectProcessor.cs index 85e4464c..e022eb9e 100644 --- a/Editor/WorldFixedObjectProcessor.cs +++ b/Editor/WorldFixedObjectProcessor.cs @@ -86,6 +86,20 @@ namespace nadena.dev.modular_avatar.core.editor obj.transform.localRotation = Quaternion.identity; 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() { @@ -96,6 +110,7 @@ namespace nadena.dev.modular_avatar.core.editor constraint.locked = true; constraint.rotationOffsets = new[] {Vector3.zero}; constraint.translationOffsets = new[] {Vector3.zero}; +#endif _proxy = obj.transform;