diff --git a/unity/Runtime/Components/MjGlobalSettings.cs b/unity/Runtime/Components/MjGlobalSettings.cs index 11e41306..58c4cf9d 100644 --- a/unity/Runtime/Components/MjGlobalSettings.cs +++ b/unity/Runtime/Components/MjGlobalSettings.cs @@ -327,7 +327,7 @@ public class MjGlobalSettings : MonoBehaviour { public static MjGlobalSettings Instance { get { if (_instance == null) { - var instances = FindObjectsOfType(); + var instances = FindObjectsByType(FindObjectsSortMode.None); if (instances.Length > 1) { throw new InvalidOperationException( "Only one MjGlobalSettings instance is allowed - please resolve manually."); diff --git a/unity/Runtime/Components/MjScene.cs b/unity/Runtime/Components/MjScene.cs index c55c5cf5..c9219d8e 100644 --- a/unity/Runtime/Components/MjScene.cs +++ b/unity/Runtime/Components/MjScene.cs @@ -50,7 +50,7 @@ public class MjScene : MonoBehaviour { public static MjScene Instance { get { if (_instance == null) { - var instances = FindObjectsOfType(); + var instances = FindObjectsByType(FindObjectsSortMode.None); if (instances.Length >= 1) { // even one is too much - _instance shouldn't have been null. throw new InvalidOperationException( "A MjScene singleton is created automatically, yet multiple instances exist."); @@ -135,7 +135,7 @@ public class MjScene : MonoBehaviour { // I briefly explored that approach, but decided against it. It increases the amount of code // on the side of the individual components. This solution allows to restrict the code in the // components to a bare minimum, at the expense of one extra method here. - var hierarchyRoots = FindObjectsOfType() + var hierarchyRoots = FindObjectsByType(FindObjectsSortMode.None) .Where(component => MjHierarchyTool.FindParentComponent(component) == null) .Select(component => component.transform) .Distinct(); @@ -209,7 +209,7 @@ public class MjScene : MonoBehaviour { // 4. rehydrate the physics scene, and sync the Unity scene to it. public unsafe void RecreateScene() { // cache joint states in order to re-apply it to the new scene - var joints = FindObjectsOfType(); + var joints = FindObjectsByType(FindObjectsSortMode.None); var positions = new Dictionary(); var velocities = new Dictionary(); foreach (var joint in joints) { diff --git a/unity/Runtime/Tools/ConvertMj2Rca.cs b/unity/Runtime/Tools/ConvertMj2Rca.cs index 1c5140bb..789c5355 100644 --- a/unity/Runtime/Tools/ConvertMj2Rca.cs +++ b/unity/Runtime/Tools/ConvertMj2Rca.cs @@ -22,8 +22,8 @@ public static class ConvertMj2Rca { private static MjActuator[] _actuators; private static MjExclude[] _excludes; public static GameObject ConvertTree(MjBody mjRoot) { - _excludes = GameObject.FindObjectsOfType(); - _actuators = GameObject.FindObjectsOfType(); + _excludes = GameObject.FindObjectsByType(FindObjectsSortMode.None); + _actuators = GameObject.FindObjectsByType(FindObjectsSortMode.None); // does it have joints with its parent? bool jointFound = false; foreach (Transform mjChild in mjRoot.transform) { @@ -283,7 +283,7 @@ public static class ConvertMj2Rca { } // The list of available ArticulationBodies changes as the recursion advances - foreach (var rcOther in GameObject.FindObjectsOfType()) { + foreach (var rcOther in GameObject.FindObjectsByType(FindObjectsSortMode.None)) { // don't add explicit exclusion to immediate parent (no children yet) if (rcParentParent != rcOther && rcOther.gameObject.name == other) { // MISSING: Physics.IgnoreCollision statements between all colliders of rcParent diff --git a/unity/Runtime/Tools/MjHierarchyTool.cs b/unity/Runtime/Tools/MjHierarchyTool.cs index 8be41966..9d4447da 100644 --- a/unity/Runtime/Tools/MjHierarchyTool.cs +++ b/unity/Runtime/Tools/MjHierarchyTool.cs @@ -72,7 +72,7 @@ public static class MjHierarchyTool { // Finds a single component that matches both the type and the name criteria. public static T FindComponentOfTypeAndName(string name) where T : MjComponent { - var components = UnityEngine.Object.FindObjectsOfType().Where( + var components = UnityEngine.Object.FindObjectsByType(FindObjectsSortMode.None).Where( component => component.gameObject.name == name); var numComponents = components.Count(); if (components == null || numComponents == 0) {