diff --git a/Editor/GeospatialCreator/Scripts/Internal/PlaceSearchWindow.cs b/Editor/GeospatialCreator/Scripts/Internal/PlaceSearchWindow.cs index b42f192..726304e 100644 --- a/Editor/GeospatialCreator/Scripts/Internal/PlaceSearchWindow.cs +++ b/Editor/GeospatialCreator/Scripts/Internal/PlaceSearchWindow.cs @@ -227,8 +227,7 @@ private int CountObjectWithComponent() int count = 0; foreach (var obj in Selection.gameObjects) { - var targetType = obj.GetComponent(); - if (targetType != null) + if (obj.TryGetComponent(out var targetType)) { count++; } diff --git a/Editor/Scripts/Internal/GeospatialCreatorEnabledWizard.cs b/Editor/Scripts/Internal/GeospatialCreatorEnabledWizard.cs index de09e3a..9db38a8 100644 --- a/Editor/Scripts/Internal/GeospatialCreatorEnabledWizard.cs +++ b/Editor/Scripts/Internal/GeospatialCreatorEnabledWizard.cs @@ -171,17 +171,15 @@ private void IsMissingDependenciesGUI() new StringBuilder("The project is missing the following required dependencies:\n"); if (_isMissingCesium) { - dependenciesText.Append( - String.Format("\n • {0} {1}+", _cesiumId, _cesiumMinVersion.ToString())); + dependenciesText.AppendFormat("\n • {0} {1}+", _cesiumId, _cesiumMinVersion.ToString()); } if (_isMissingUnityMath) { - dependenciesText.Append( - String.Format( + dependenciesText.AppendFormat( "\n • {0} {1}+", _unityMathId, - _unityMathMinVersion.ToString())); + _unityMathMinVersion.ToString()); } dependenciesText.Append("\n\nSee the Quickstart Guide for more information."); diff --git a/Editor/Scripts/Internal/LogRequestUtils.cs b/Editor/Scripts/Internal/LogRequestUtils.cs index aeb9a59..6c8d1a3 100644 --- a/Editor/Scripts/Internal/LogRequestUtils.cs +++ b/Editor/Scripts/Internal/LogRequestUtils.cs @@ -141,7 +141,7 @@ private static string UniqueId() private static string SessionId() { // Generate on first request. - if (_sessionId == string.Empty) + if (string.IsNullOrEmpty(_sessionId)) { _sessionId = Guid.NewGuid().ToString(); } diff --git a/Runtime/GeospatialCreatorRuntime/Scripts/ARGeospatialCreatorAnchor.cs b/Runtime/GeospatialCreatorRuntime/Scripts/ARGeospatialCreatorAnchor.cs index a5ba0bd..ff43f5a 100644 --- a/Runtime/GeospatialCreatorRuntime/Scripts/ARGeospatialCreatorAnchor.cs +++ b/Runtime/GeospatialCreatorRuntime/Scripts/ARGeospatialCreatorAnchor.cs @@ -718,8 +718,12 @@ private void FinishAnchor(ARGeospatialAnchor resolvedAnchor) // ARGeospatialAnchor by making the creator anchor a child of the runtime anchor. // We zero out the pose & rotation on the creator anchor, since the runtime // anchor will handle that from now on. +#if UNITY_2022_3_OR_NEWER + transform.SetPositionAndRotation(new Vector3(0, 0, 0), Quaternion.identity); +#else transform.position = new Vector3(0, 0, 0); transform.rotation = Quaternion.identity; +#endif transform.SetParent(resolvedAnchor.transform, false); _anchorResolution = AnchorResolutionState.Complete; diff --git a/Runtime/Scripts/ARCloudAnchor.cs b/Runtime/Scripts/ARCloudAnchor.cs index 9b4b809..a03230c 100644 --- a/Runtime/Scripts/ARCloudAnchor.cs +++ b/Runtime/Scripts/ARCloudAnchor.cs @@ -171,8 +171,12 @@ public void Update() _pose = apiPose.ToUnityPose(); // Update the Cloud Anchor transform to match. +#if UNITY_2022_3_OR_NEWER + transform.SetLocalPositionAndRotation(_pose.position, _pose.rotation); +#else transform.localPosition = _pose.position; transform.localRotation = _pose.rotation; +#endif } /// diff --git a/Runtime/Scripts/ARCoreExtensionsConfig.cs b/Runtime/Scripts/ARCoreExtensionsConfig.cs index 515c087..f61294f 100644 --- a/Runtime/Scripts/ARCoreExtensionsConfig.cs +++ b/Runtime/Scripts/ARCoreExtensionsConfig.cs @@ -131,16 +131,11 @@ public HelpAttribute GetSemanticModeHelpInfo() public override bool Equals(object other) { ARCoreExtensionsConfig otherConfig = other as ARCoreExtensionsConfig; - if (otherConfig == null || - SemanticMode != otherConfig.SemanticMode || - GeospatialMode != otherConfig.GeospatialMode || - StreetscapeGeometryMode != otherConfig.StreetscapeGeometryMode || - CloudAnchorMode != otherConfig.CloudAnchorMode) - { - return false; - } - - return true; + return otherConfig != null && + SemanticMode == otherConfig.SemanticMode && + GeospatialMode == otherConfig.GeospatialMode && + StreetscapeGeometryMode == otherConfig.StreetscapeGeometryMode && + CloudAnchorMode == otherConfig.CloudAnchorMode; } /// diff --git a/Runtime/Scripts/ARGeospatialAnchor.cs b/Runtime/Scripts/ARGeospatialAnchor.cs index c421a04..caafbca 100644 --- a/Runtime/Scripts/ARGeospatialAnchor.cs +++ b/Runtime/Scripts/ARGeospatialAnchor.cs @@ -134,8 +134,12 @@ public void Update() _pose = apiPose.ToUnityPose(); // Update the Geospatial Anchor transform to match. +#if UNITY_2022_3_OR_NEWER + transform.SetLocalPositionAndRotation(_pose.position, _pose.rotation); +#else transform.localPosition = _pose.position; transform.localRotation = _pose.rotation; +#endif } /// diff --git a/Runtime/Scripts/Internal/DependentModules/FeatureModules/LocationModule.cs b/Runtime/Scripts/Internal/DependentModules/FeatureModules/LocationModule.cs index eb23b86..98c5ca8 100644 --- a/Runtime/Scripts/Internal/DependentModules/FeatureModules/LocationModule.cs +++ b/Runtime/Scripts/Internal/DependentModules/FeatureModules/LocationModule.cs @@ -65,14 +65,9 @@ public override string[] GetRuntimePermissions(ARCoreExtensionsConfig sessionCon public override bool IsEnabled(ARCoreExtensionsProjectSettings settings, UnityEditor.BuildTarget buildTarget) { - if (settings.GeospatialEnabled && + return settings.GeospatialEnabled && (buildTarget == UnityEditor.BuildTarget.Android || - (settings.IsIOSSupportEnabled && buildTarget == UnityEditor.BuildTarget.iOS))) - { - return true; - } - - return false; + (settings.IsIOSSupportEnabled && buildTarget == UnityEditor.BuildTarget.iOS)); } @@ -291,12 +286,7 @@ public override JarArtifact[] GetAndroidDependencies( /// True if location should be used; otherwise, return false. private static bool UseLocation(ARCoreExtensionsConfig sessionConfig) { - if (sessionConfig.GeospatialMode != GeospatialMode.Disabled) - { - return true; - } - - return false; + return sessionConfig.GeospatialMode != GeospatialMode.Disabled; } } } diff --git a/Samples~/Geospatial/Scripts/GeospatialController.cs b/Samples~/Geospatial/Scripts/GeospatialController.cs index d73e970..130cd41 100644 --- a/Samples~/Geospatial/Scripts/GeospatialController.cs +++ b/Samples~/Geospatial/Scripts/GeospatialController.cs @@ -818,8 +818,12 @@ private void InstantiateRenderObject(ARStreetscapeGeometry streetscapegeometry) StreetscapeGeometryMaterialTerrain; } +#if UNITY_2022_3_OR_NEWER + renderObject.transform.SetPositionAndRotation(streetscapegeometry.pose.position, streetscapegeometry.pose.rotation); +#else renderObject.transform.position = streetscapegeometry.pose.position; renderObject.transform.rotation = streetscapegeometry.pose.rotation; +#endif _streetscapegeometryGOs.Add(streetscapegeometry.trackableId, renderObject); } @@ -836,8 +840,12 @@ private void UpdateRenderObject(ARStreetscapeGeometry streetscapegeometry) if (_streetscapegeometryGOs.ContainsKey(streetscapegeometry.trackableId)) { GameObject renderObject = _streetscapegeometryGOs[streetscapegeometry.trackableId]; +#if UNITY_2022_3_OR_NEWER + renderObject.transform.SetPositionAndRotation(streetscapegeometry.pose.position, streetscapegeometry.pose.rotation); +#else renderObject.transform.position = streetscapegeometry.pose.position; renderObject.transform.rotation = streetscapegeometry.pose.rotation; +#endif } }