Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion org.mixedrealitytoolkit.core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ 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 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 #1056](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/1056)

### 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)

## [4.0.0-development.pre.1] - 2024-07-09

Expand Down
54 changes: 54 additions & 0 deletions org.mixedrealitytoolkit.core/Utilities/FindObjectUtility.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright (c) Mixed Reality Toolkit Contributors
// Licensed under the BSD 3-Clause

using System;
using UnityEngine;

namespace MixedReality.Toolkit
{
/// <summary>
/// A static utility used to avoid deprecated Find Object functions in favor of replacements introduced in Unity >= 2021.3.18.
/// </summary>
[Obsolete("FindObjectUtility has been deprecated in version 4.0.0. Please use the corresponding UnityEngine.Object methods instead.")]
public static class FindObjectUtility
{
/// <summary>
/// Returns the first object matching the specified type.
/// </summary>
/// <param name="includeInactive">If true, inactive objects will be included in the search. False by default.</param>
public static T FindFirstObjectByType<T>(bool includeInactive = false) where T : Component
{
return UnityEngine.Object.FindFirstObjectByType<T>(includeInactive ? FindObjectsInactive.Include : FindObjectsInactive.Exclude);
}

/// <summary>
/// Returns an object matching the specified type.
/// </summary>
/// <param name="includeInactive">If true, inactive objects will be included in the search. False by default.</param>
public static T FindAnyObjectByType<T>(bool includeInactive = false) where T : Component
{
return UnityEngine.Object.FindAnyObjectByType<T>(includeInactive ? FindObjectsInactive.Include : FindObjectsInactive.Exclude);
}

/// <summary>
/// Returns all objects matching the specified type.
/// </summary>
/// <param name="includeInactive">If true, inactive objects will be included in the search. False by default.</param>
/// <param name="sort">If false, results will not sorted by InstanceID. True by default.</param>
public static T[] FindObjectsByType<T>(bool includeInactive = false, bool sort = true) where T : Component
{
return UnityEngine.Object.FindObjectsByType<T>(includeInactive ? FindObjectsInactive.Include : FindObjectsInactive.Exclude, sort ? FindObjectsSortMode.InstanceID : FindObjectsSortMode.None);
}

/// <summary>
/// Returns all objects matching the specified type.
/// </summary>
/// <param name="includeInactive">If true, inactive objects will be included in the search. False by default.</param>
/// <param name="sort">If false, results will not sorted by InstanceID. True by default.</param>
/// <param name="type">The type to search for.</param>
public static UnityEngine.Object[] FindObjectsByType(Type type, bool includeInactive = false, bool sort = true)
{
return UnityEngine.Object.FindObjectsByType(type, includeInactive ? FindObjectsInactive.Include : FindObjectsInactive.Exclude, sort ? FindObjectsSortMode.InstanceID : FindObjectsSortMode.None);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace MixedReality.Toolkit.SpatialManipulation
/// Scale handles subclass this to implement custom occlusion + reorientation logic.
/// </summary>
[AddComponentMenu("MRTK/Spatial Manipulation/Bounds Handle Interactable")]
public class BoundsHandleInteractable : StatefulInteractable, ISnapInteractable
public class BoundsHandleInteractable : StatefulInteractable, ISnapInteractable, ISerializationCallbackReceiver
{
private BoundsControl boundsControlRoot;

Expand Down Expand Up @@ -57,6 +57,41 @@ public BoundsControl BoundsControlRoot
[Tooltip("Maximum lossy scale for the handle. Only applicable if ScaleAdjustType is Advanced.")]
private float maxLossyScale = 4f;

#region Handling Obsolete Properties

// A temporary variable used to migrate instances of BoundsHandleInteractable to use the scaleMaintainType property
// instead of the serialized field maintainGlobalSize.
// TODO: Remove this after some time to ensure users have successfully migrated.
[SerializeField, HideInInspector]
private bool migratedSuccessfully = false;

[SerializeField, HideInInspector]
private bool maintainGlobalSize = true;

/// <summary>
/// Should the handle maintain its global size, even as the object changes size?
/// </summary>
[Obsolete("This property has been deprecated in version 3.4.0. Use ScaleMaintainType instead.")]
public bool MaintainGlobalSize
{
get => scaleMaintainType == ScaleMaintainType.GlobalSize;
set => scaleMaintainType = value ? ScaleMaintainType.GlobalSize : ScaleMaintainType.FixedScale;
}

public void OnBeforeSerialize() { }

public void OnAfterDeserialize()
{
// Only update the scaleMaintainType if it hasn't been set and the old property was not migrated yet
if (!migratedSuccessfully && scaleMaintainType == ScaleMaintainType.GlobalSize)
{
scaleMaintainType = maintainGlobalSize ? ScaleMaintainType.GlobalSize : ScaleMaintainType.FixedScale;
migratedSuccessfully = true;
}
}

#endregion Handling Obsolete Properties

#endregion Bounds Handle Scaling

#region ISnapInteractable
Expand Down