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
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ private int CountObjectWithComponent<T>()
int count = 0;
foreach (var obj in Selection.gameObjects)
{
var targetType = obj.GetComponent<T>();
if (targetType != null)
if (obj.TryGetComponent<T>(out var targetType))
{
count++;
}
Expand Down
8 changes: 3 additions & 5 deletions Editor/Scripts/Internal/GeospatialCreatorEnabledWizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
2 changes: 1 addition & 1 deletion Editor/Scripts/Internal/LogRequestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions Runtime/Scripts/ARCloudAnchor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/// <summary>
Expand Down
15 changes: 5 additions & 10 deletions Runtime/Scripts/ARCoreExtensionsConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/// <summary>
Expand Down
4 changes: 4 additions & 0 deletions Runtime/Scripts/ARGeospatialAnchor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

}

Expand Down Expand Up @@ -291,12 +286,7 @@ public override JarArtifact[] GetAndroidDependencies(
/// <returns>True if location should be used; otherwise, return false.</returns>
private static bool UseLocation(ARCoreExtensionsConfig sessionConfig)
{
if (sessionConfig.GeospatialMode != GeospatialMode.Disabled)
{
return true;
}

return false;
return sessionConfig.GeospatialMode != GeospatialMode.Disabled;
}
}
}
8 changes: 8 additions & 0 deletions Samples~/Geospatial/Scripts/GeospatialController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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
}
}

Expand Down