From 036ee1a8049d548604dd098a9c8da7dbad370b9e Mon Sep 17 00:00:00 2001 From: Kurtis Date: Tue, 4 Nov 2025 11:49:44 -0800 Subject: [PATCH 1/4] Deprecate EnumFlagsAttribute --- .../Utilities/Attributes/EnumFlagsAttribute.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/org.mixedrealitytoolkit.core/Utilities/Attributes/EnumFlagsAttribute.cs b/org.mixedrealitytoolkit.core/Utilities/Attributes/EnumFlagsAttribute.cs index 71fdefe15..c2607c8e2 100644 --- a/org.mixedrealitytoolkit.core/Utilities/Attributes/EnumFlagsAttribute.cs +++ b/org.mixedrealitytoolkit.core/Utilities/Attributes/EnumFlagsAttribute.cs @@ -14,6 +14,7 @@ namespace MixedReality.Toolkit /// From https://answers.unity.com/questions/486694/default-editor-enum-as-flags-.html /// [AttributeUsage(AttributeTargets.Field)] + [Obsolete("Use Unity.XR.CoreUtils.GUI.FlagsPropertyAttribute instead.")] public sealed class EnumFlagsAttribute : PropertyAttribute { /// @@ -21,4 +22,4 @@ public sealed class EnumFlagsAttribute : PropertyAttribute /// public EnumFlagsAttribute() { } } -} \ No newline at end of file +} From 723561cccd25b5eb681ab5301b283113b130b559 Mon Sep 17 00:00:00 2001 From: Kurtis Date: Tue, 4 Nov 2025 11:52:10 -0800 Subject: [PATCH 2/4] Replace EnumFlags -> FlagsProperty --- .../BoundsControl/BoundsControl.cs | 13 ++++--------- .../Constraints/MoveAxisConstraint.cs | 4 ++-- .../Constraints/RotationAxisConstraint.cs | 4 ++-- .../Constraints/TransformConstraint.cs | 8 +++----- .../ObjectManipulator/ObjectManipulator.cs | 7 +++---- .../Solvers/Follow.cs | 4 ++-- .../Interop/UGUIInputAdapter.cs | 10 +++++----- 7 files changed, 21 insertions(+), 29 deletions(-) diff --git a/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControl.cs b/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControl.cs index a2592ae0a..c72022441 100644 --- a/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControl.cs +++ b/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControl.cs @@ -1,15 +1,12 @@ // Copyright (c) Mixed Reality Toolkit Contributors // Licensed under the BSD 3-Clause +using System; using Unity.Profiling; +using Unity.XR.CoreUtils.GUI; using UnityEngine; using UnityEngine.XR.Interaction.Toolkit; using static MixedReality.Toolkit.SpatialManipulation.ObjectManipulator; -using System; - -#if UNITY_EDITOR -using UnityEditor; -#endif namespace MixedReality.Toolkit.SpatialManipulation { @@ -262,8 +259,7 @@ public HandleType EnabledHandles set => enabledHandles = value; } - [EnumFlags] - [SerializeField] + [SerializeField, FlagsProperty] [Tooltip("Specifies whether the rotate handles will rotate the object around its origin, or the center of its calculated bounds.")] private RotateAnchorType rotateAnchor = RotateAnchorType.BoundsCenter; @@ -282,8 +278,7 @@ public RotateAnchorType RotateAnchor } } - [EnumFlags] - [SerializeField] + [SerializeField, FlagsProperty] [Tooltip("Specifies whether the scale handles will rotate the object around their opposing corner, or the center of its calculated bounds.")] private ScaleAnchorType scaleAnchor = ScaleAnchorType.OppositeCorner; diff --git a/org.mixedrealitytoolkit.spatialmanipulation/Constraints/MoveAxisConstraint.cs b/org.mixedrealitytoolkit.spatialmanipulation/Constraints/MoveAxisConstraint.cs index 7694ea4f5..032760021 100644 --- a/org.mixedrealitytoolkit.spatialmanipulation/Constraints/MoveAxisConstraint.cs +++ b/org.mixedrealitytoolkit.spatialmanipulation/Constraints/MoveAxisConstraint.cs @@ -1,6 +1,7 @@ // Copyright (c) Mixed Reality Toolkit Contributors // Licensed under the BSD 3-Clause +using Unity.XR.CoreUtils.GUI; using UnityEngine; namespace MixedReality.Toolkit.SpatialManipulation @@ -18,8 +19,7 @@ public class MoveAxisConstraint : TransformConstraint { #region Properties - [SerializeField] - [EnumFlags] + [SerializeField, FlagsProperty] [Tooltip("Constrain movement along an axis")] private AxisFlags constraintOnMovement = 0; diff --git a/org.mixedrealitytoolkit.spatialmanipulation/Constraints/RotationAxisConstraint.cs b/org.mixedrealitytoolkit.spatialmanipulation/Constraints/RotationAxisConstraint.cs index 8ccea8cff..2d07ad2b5 100644 --- a/org.mixedrealitytoolkit.spatialmanipulation/Constraints/RotationAxisConstraint.cs +++ b/org.mixedrealitytoolkit.spatialmanipulation/Constraints/RotationAxisConstraint.cs @@ -1,6 +1,7 @@ // Copyright (c) Mixed Reality Toolkit Contributors // Licensed under the BSD 3-Clause +using Unity.XR.CoreUtils.GUI; using UnityEngine; namespace MixedReality.Toolkit.SpatialManipulation @@ -17,8 +18,7 @@ public class RotationAxisConstraint : TransformConstraint { #region Properties - [SerializeField] - [EnumFlags] + [SerializeField, FlagsProperty] [Tooltip("Constrain rotation about an axis")] private AxisFlags constraintOnRotation = 0; diff --git a/org.mixedrealitytoolkit.spatialmanipulation/Constraints/TransformConstraint.cs b/org.mixedrealitytoolkit.spatialmanipulation/Constraints/TransformConstraint.cs index 58012bc1e..d9e13e7a4 100644 --- a/org.mixedrealitytoolkit.spatialmanipulation/Constraints/TransformConstraint.cs +++ b/org.mixedrealitytoolkit.spatialmanipulation/Constraints/TransformConstraint.cs @@ -1,7 +1,7 @@ // Copyright (c) Mixed Reality Toolkit Contributors // Licensed under the BSD 3-Clause -using System; +using Unity.XR.CoreUtils.GUI; using UnityEngine; namespace MixedReality.Toolkit.SpatialManipulation @@ -17,8 +17,7 @@ public abstract class TransformConstraint : MonoBehaviour { #region Properties - [SerializeField] - [EnumFlags] + [SerializeField, FlagsProperty] [Tooltip("What type of manipulation this constraint applies to. Defaults to One Handed and Two Handed.")] private ManipulationHandFlags handType = ManipulationHandFlags.OneHanded | ManipulationHandFlags.TwoHanded; @@ -31,8 +30,7 @@ public ManipulationHandFlags HandType set => handType = value; } - [SerializeField] - [EnumFlags] + [SerializeField, FlagsProperty] [Tooltip("What type of manipulation this constraint applies to. Defaults to Near and Far.")] private ManipulationProximityFlags proximityType = ManipulationProximityFlags.Near | ManipulationProximityFlags.Far; diff --git a/org.mixedrealitytoolkit.spatialmanipulation/ObjectManipulator/ObjectManipulator.cs b/org.mixedrealitytoolkit.spatialmanipulation/ObjectManipulator/ObjectManipulator.cs index a89a8406e..ebabb9cbb 100644 --- a/org.mixedrealitytoolkit.spatialmanipulation/ObjectManipulator/ObjectManipulator.cs +++ b/org.mixedrealitytoolkit.spatialmanipulation/ObjectManipulator/ObjectManipulator.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using Unity.Profiling; +using Unity.XR.CoreUtils.GUI; using UnityEngine; using UnityEngine.Serialization; using UnityEngine.XR.Interaction.Toolkit; @@ -135,8 +136,7 @@ public Transform HostTransform } } - [SerializeField] - [EnumFlags] + [SerializeField, FlagsProperty] [Tooltip("What kinds of manipulation should be allowed?")] private TransformFlags allowedManipulations = TransformFlags.Move | TransformFlags.Rotate | TransformFlags.Scale; @@ -288,8 +288,7 @@ public RotateAnchorType RotationAnchorFar set => rotationAnchorFar = value; } - [SerializeField] - [EnumFlags] + [SerializeField, FlagsProperty] [Tooltip("Rigid body behavior of the dragged object when releasing it.")] private ReleaseBehaviorType releaseBehavior = ReleaseBehaviorType.KeepVelocity | ReleaseBehaviorType.KeepAngularVelocity; diff --git a/org.mixedrealitytoolkit.spatialmanipulation/Solvers/Follow.cs b/org.mixedrealitytoolkit.spatialmanipulation/Solvers/Follow.cs index ac030a838..3d76b65a7 100644 --- a/org.mixedrealitytoolkit.spatialmanipulation/Solvers/Follow.cs +++ b/org.mixedrealitytoolkit.spatialmanipulation/Solvers/Follow.cs @@ -2,6 +2,7 @@ // Licensed under the BSD 3-Clause using Unity.Profiling; +using Unity.XR.CoreUtils.GUI; using UnityEngine; using UnityEngine.Serialization; @@ -69,8 +70,7 @@ public Transform TargetToFace set => targetToFace = value; } - [SerializeField] - [EnumFlags] + [SerializeField, FlagsProperty] [Tooltip("Rotation axes used when facing target.")] private AxisFlags pivotAxis = AxisFlags.XAxis | AxisFlags.YAxis | AxisFlags.ZAxis; diff --git a/org.mixedrealitytoolkit.uxcore/Interop/UGUIInputAdapter.cs b/org.mixedrealitytoolkit.uxcore/Interop/UGUIInputAdapter.cs index 26723be67..7b6db7aba 100644 --- a/org.mixedrealitytoolkit.uxcore/Interop/UGUIInputAdapter.cs +++ b/org.mixedrealitytoolkit.uxcore/Interop/UGUIInputAdapter.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; +using Unity.XR.CoreUtils.GUI; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; @@ -38,8 +39,7 @@ protected IXRInteractable ThisInteractable } } - [SerializeField] - [EnumFlags] + [SerializeField, FlagsProperty] [Tooltip("Which axes should be used for manipulation instead of navigation?")] private AxisFlags movableAxes = 0; @@ -109,9 +109,9 @@ internal protected XRInteractionManager InteractionManager /// A Unity Editor only event function that is called when the script is loaded or a value changes in the Unity Inspector. /// protected override void OnValidate() - { + { base.OnValidate(); - + // Validate that no transition type is set. You shouldn't be using this // for any sort of UI visuals; use a StatefulInteractable and a // StateVisualizer instead, even for UI. @@ -416,7 +416,7 @@ protected IEnumerator Move(Vector3 objectLocalDelta) } } } - + /// /// Called when the Unity UGUI element is selected. /// From 6d71ed9efbfd7b41b12c271af5f8c74dfac028d6 Mon Sep 17 00:00:00 2001 From: Kurtis Date: Tue, 4 Nov 2025 11:53:21 -0800 Subject: [PATCH 3/4] Minor alignment of attributes --- .../BoundsControl/BoundsControl.cs | 22 ++++++--------- .../ObjectManipulator/ObjectManipulator.cs | 28 +++++++------------ 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControl.cs b/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControl.cs index c72022441..e968e5259 100644 --- a/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControl.cs +++ b/org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsControl.cs @@ -105,8 +105,7 @@ public bool OverrideBounds } } - [SerializeField] - [DrawIf("overrideBounds")] + [SerializeField, DrawIf("overrideBounds")] [Tooltip("The bounds will be calculated from this object and this object only, instead of the entire hierarchy.")] private Transform boundsOverride; @@ -196,8 +195,7 @@ public bool ToggleHandlesOnClick set => toggleHandlesOnClick = value; } - [SerializeField] - [DrawIf("toggleHandlesOnClick")] + [SerializeField, DrawIf("toggleHandlesOnClick")] [Tooltip("During a selection of the associated interactable, if the interactable is dragged/moved a smaller distance than this value, the handles will be activated/deactivated.")] private float dragToggleThreshold = 0.02f; @@ -331,8 +329,7 @@ public bool SmoothingActive set => smoothingActive = value; } - [SerializeField] - [DrawIf("smoothingActive")] + [SerializeField, DrawIf("smoothingActive")] [Tooltip("Enter amount representing amount of smoothing to apply to the rotation. Smoothing of 0 means no smoothing. Max value means no change to value.")] private float rotateLerpTime = 0.00001f; @@ -345,8 +342,7 @@ public float RotateLerpTime set => rotateLerpTime = value; } - [SerializeField] - [DrawIf("smoothingActive")] + [SerializeField, DrawIf("smoothingActive")] [Tooltip("Enter amount representing amount of smoothing to apply to the scale. Smoothing of 0 means no smoothing. Max value means no change to value.")] private float scaleLerpTime = 0.00001f; @@ -359,8 +355,7 @@ public float ScaleLerpTime set => scaleLerpTime = value; } - [SerializeField] - [DrawIf("smoothingActive")] + [SerializeField, DrawIf("smoothingActive")] [Tooltip("Enter amount representing amount of smoothing to apply to the translation. " + "Smoothing of 0 means no smoothing. Max value means no change to value.")] private float translateLerpTime = 0.00001f; @@ -390,8 +385,7 @@ public bool EnableConstraints set => enableConstraints = value; } - [SerializeField] - [DrawIf("enableConstraints")] + [SerializeField, DrawIf("enableConstraints")] [Tooltip("Constraint manager slot to enable constraints when manipulating the object.")] private ConstraintManager constraintsManager; /// @@ -434,7 +428,7 @@ public LogicType ManipulationLogicTypes [Header("Events")] [SerializeField] - SelectEnterEvent manipulationStarted = new SelectEnterEvent(); + private SelectEnterEvent manipulationStarted = new SelectEnterEvent(); /// /// Fired when manipulation on a handle begins. @@ -446,7 +440,7 @@ public SelectEnterEvent ManipulationStarted } [SerializeField] - SelectExitEvent manipulationEnded = new SelectExitEvent(); + private SelectExitEvent manipulationEnded = new SelectExitEvent(); /// /// Fired when manipulation on a handle ends. diff --git a/org.mixedrealitytoolkit.spatialmanipulation/ObjectManipulator/ObjectManipulator.cs b/org.mixedrealitytoolkit.spatialmanipulation/ObjectManipulator/ObjectManipulator.cs index ebabb9cbb..8f70d1d5c 100644 --- a/org.mixedrealitytoolkit.spatialmanipulation/ObjectManipulator/ObjectManipulator.cs +++ b/org.mixedrealitytoolkit.spatialmanipulation/ObjectManipulator/ObjectManipulator.cs @@ -70,7 +70,7 @@ public enum RotateAnchorType /// This enumeration describing the type of behavior to apply when a /// is released by a controller. /// - [System.Flags] + [Flags] public enum ReleaseBehaviorType { /// @@ -206,8 +206,7 @@ public bool ApplyTorque set => applyTorque = value; } - [SerializeField] - [Range(0.001f, 2.0f)] + [SerializeField, Range(0.001f, 2.0f)] [Tooltip("The time scale at which a Rigidbody reacts to input movement defined as oscillation period of the dampened spring force.")] private float springForceSoftness = 0.1f; @@ -220,8 +219,7 @@ public float SpringForceSoftness set => springForceSoftness = value; } - [SerializeField] - [Range(0.001f, 2.0f)] + [SerializeField, Range(0.001f, 2.0f)] [Tooltip("The time scale at which a Rigidbody reacts to input rotation defined as oscillation period of the dampened spring torque.")] private float springTorqueSoftness = 0.1f; @@ -234,9 +232,8 @@ public float SpringTorqueSoftness set => springTorqueSoftness = value; } - [SerializeField] - [Range(0, 2.0f)] - [Tooltip("The damping of the spring force&torque. A value of one corresponds to critical damping, lower values lead to under damping or oscillation.")] + [SerializeField, Range(0, 2.0f)] + [Tooltip("The damping of the spring force & torque. A value of one corresponds to critical damping, lower values lead to under damping or oscillation.")] private float springDamping = 1.0f; /// @@ -248,8 +245,7 @@ public float SpringDamping set => springDamping = value; } - [SerializeField] - [Range(0, 10000f)] + [SerializeField, Range(0, 10000f)] [Tooltip("The maximum acceleration applied by the spring force to avoid trembling when pushing a body against a static object.")] private float springForceLimit = 100.0f; @@ -324,8 +320,7 @@ public SystemType TransformSmoothingLogicType } } - [FormerlySerializedAs("smoothingActive")] - [SerializeField] + [SerializeField, FormerlySerializedAs("smoothingActive")] [Tooltip("Frame-rate independent smoothing for far interactions. Far smoothing is enabled by default.")] private bool smoothingFar = true; @@ -357,8 +352,7 @@ public bool SmoothingNear set => smoothingNear = value; } - [SerializeField] - [Range(0, 1)] + [SerializeField, Range(0, 1)] [Tooltip("Enter amount representing amount of smoothing to apply to the movement. Smoothing of 0 means no smoothing. Max value means no change to value.")] private float moveLerpTime = 0.001f; @@ -371,8 +365,7 @@ public float MoveLerpTime set => moveLerpTime = value; } - [SerializeField] - [Range(0, 1)] + [SerializeField, Range(0, 1)] [Tooltip("Enter amount representing amount of smoothing to apply to the rotation. Smoothing of 0 means no smoothing. Max value means no change to value.")] private float rotateLerpTime = 0.001f; @@ -385,8 +378,7 @@ public float RotateLerpTime set => rotateLerpTime = value; } - [SerializeField] - [Range(0, 1)] + [SerializeField, Range(0, 1)] [Tooltip("Enter amount representing amount of smoothing to apply to the scale. Smoothing of 0 means no smoothing. Max value means no change to value.")] private float scaleLerpTime = 0.001f; From 105fc8b79f3dbafba6bb5a7fec76182e9e63fba0 Mon Sep 17 00:00:00 2001 From: Kurtis Date: Wed, 12 Nov 2025 13:03:34 -0800 Subject: [PATCH 4/4] Update CHANGELOG.md --- org.mixedrealitytoolkit.core/CHANGELOG.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/org.mixedrealitytoolkit.core/CHANGELOG.md b/org.mixedrealitytoolkit.core/CHANGELOG.md index ffe977dc0..9418c6d51 100644 --- a/org.mixedrealitytoolkit.core/CHANGELOG.md +++ b/org.mixedrealitytoolkit.core/CHANGELOG.md @@ -2,6 +2,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). +## Unreleased + +### Deprecated + +* Deprecated `EnumFlagsAttribute` in favor of `Unity.XR.CoreUtils.GUI.FlagsPropertyAttribute`. [PR #1075](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/1075) + ## [4.0.0-pre.2] - 2025-12-05 ### Added @@ -16,12 +22,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ### Removed -* Removed ITrackedInteractor, as it was supporting an unused codepath and there are better ways to get this data (like querying the attach transform). [PR #1044](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/1044) +* Removed `ITrackedInteractor`, as it was supporting an unused codepath and there are better ways to get this data (like querying the attach transform). [PR #1044](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/1044) ### Deprecated -* Deprecated IHandedInteractor, as its info is now queryable directly from IXRInteractor's handedness property. [PR #1042](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/1042) -* Deprecated FindObjectUtility, as it was a backwards-compatibility layer for pre-2021.3.18. Since our min version is now 2022.3, we can just call the API directly. [PR #1058](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/1058) +* Deprecated `IHandedInteractor`, as its info is now queryable directly from IXRInteractor's handedness property. [PR #1042](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/1042) +* Deprecated `FindObjectUtility`, as it was a backwards-compatibility layer for pre-2021.3.18. Since our min version is now 2022.3, we can just call the API directly. [PR #1058](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/1058) ## [4.0.0-pre.1] - 2024-07-09