浏览代码

Update packages to 4.1.1 verified

/4.1
Tim Mowrer 3 年前
当前提交
e61130f8
共有 8 个文件被更改,包括 479 次插入534 次删除
  1. 1
      .gitignore
  2. 353
      Assets/Scenes/ARKit/ARKitGeoAnchors/ARKitGeoAnchors.unity
  3. 226
      Assets/Scenes/ARKit/ARKitGeoAnchors/EnableGeoAnchors.cs
  4. 9
      Assets/Scripts/UX/CheckAvailableFeatures.cs
  5. 8
      Packages/manifest.json
  6. 4
      ProjectSettings/ProjectVersion.txt
  7. 2
      README.md
  8. 410
      Packages/packages-lock.json

1
.gitignore


[Bb]uilds/
[Uu]serSettings/
Assets/AssetStoreTools*
Packages/packages-lock.json
# Visual Studio 2015 cache directory
/.vs/

353
Assets/Scenes/ARKit/ARKitGeoAnchors/ARKitGeoAnchors.unity


m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &608673026
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 608673029}
- component: {fileID: 608673028}
- component: {fileID: 608673027}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &608673027
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 608673026}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &608673028
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 608673026}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &608673029
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 608673026}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &793213725
GameObject:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 83ef5ba9cc0da4a19a969308a48e993d, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &999347780
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 1370236719}
m_Modifications:
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_SizeDelta.x
value: 100
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_SizeDelta.y
value: 100
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_AnchorMin.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_AnchorMin.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_AnchorMax.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 3225625820226493293, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_Name
value: BackButtonManager
objectReference: {fileID: 0}
- target: {fileID: 3475649454728415072, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_AnchoredPosition.x
value: -150
objectReference: {fileID: 0}
- target: {fileID: 3475649454728415072, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -150
objectReference: {fileID: 0}
- target: {fileID: 3475649454728415073, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3475649454728415075, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 999347783}
- target: {fileID: 3475649454728415075, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: BackButtonPressed
objectReference: {fileID: 0}
- target: {fileID: 4584729703009679669, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_BackButton
value:
objectReference: {fileID: 999347782}
- target: {fileID: 4792654351133402651, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_AnchoredPosition.x
value: -150
objectReference: {fileID: 0}
- target: {fileID: 4792654351133402651, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -150
objectReference: {fileID: 0}
- target: {fileID: 6193553896759373505, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 4ee22c1f54b174122b6a766fe09e0de8, type: 3}
--- !u!224 &999347781 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
m_PrefabInstance: {fileID: 999347780}
m_PrefabAsset: {fileID: 0}
--- !u!1 &999347782 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 6193553896759373505, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
m_PrefabInstance: {fileID: 999347780}
m_PrefabAsset: {fileID: 0}
--- !u!114 &999347783 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 4584729703009679669, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
m_PrefabInstance: {fileID: 999347780}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9909048d5fe6c41468a28c79b85916d5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1198095225
GameObject:
m_ObjectHideFlags: 0

m_Father: {fileID: 277780416}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1370236715
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1370236719}
- component: {fileID: 1370236718}
- component: {fileID: 1370236717}
- component: {fileID: 1370236716}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1370236716
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1370236715}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &1370236717
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1370236715}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
--- !u!223 &1370236718
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1370236715}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!224 &1370236719
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1370236715}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 999347781}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!1 &1494310549
GameObject:
m_ObjectHideFlags: 0

226
Assets/Scenes/ARKit/ARKitGeoAnchors/EnableGeoAnchors.cs


#if UNITY_IOS
using System.Runtime.InteropServices;
using UnityEngine.XR.ARKit;
#endif
// This custom ConfigurationChooser tells the ARKit XR Plugin to use an ARGeoTrackingConfiguration
// See https://developer.apple.com/documentation/arkit/argeotrackingconfiguration?language=objc
class ARGeoAnchorConfigurationChooser : ConfigurationChooser
namespace UnityEngine.XR.ARFoundation.Samples
static readonly ConfigurationChooser s_DefaultChooser = new DefaultConfigurationChooser();
#if UNITY_IOS && !UNITY_EDITOR
// This custom ConfigurationChooser tells the ARKit XR Plugin to use an ARGeoTrackingConfiguration
// See https://developer.apple.com/documentation/arkit/argeotrackingconfiguration?language=objc
class ARGeoAnchorConfigurationChooser : ConfigurationChooser
{
static readonly ConfigurationChooser s_DefaultChooser = new DefaultConfigurationChooser();
static readonly ConfigurationDescriptor s_ARGeoConfigurationDescriptor = new ConfigurationDescriptor(
// On iOS, the "identifier" used by the ConfigurationDescriptor is the Objective-C metaclass for the type
// of configuration that should be used. In general, you should not create new ConfigurationDescriptors
// (you should pick one of the descriptors passed into ChooseConfiguration); however, this will do for this
// specific case.
ARGeoTrackingConfigurationClass,
static readonly ConfigurationDescriptor s_ARGeoConfigurationDescriptor = new ConfigurationDescriptor(
// On iOS, the "identifier" used by the ConfigurationDescriptor is the Objective-C metaclass for the type
// of configuration that should be used. In general, you should not create new ConfigurationDescriptors
// (you should pick one of the descriptors passed into ChooseConfiguration); however, this will do for this
// specific case.
ARGeoTrackingConfigurationClass,
// These are the "features" supported by the ARGeoTrackingConfiguration
Feature.WorldFacingCamera |
Feature.PositionAndRotation |
Feature.ImageTracking |
Feature.PlaneTracking |
Feature.ObjectTracking |
Feature.EnvironmentProbes,
// These are the "features" supported by the ARGeoTrackingConfiguration
Feature.WorldFacingCamera |
Feature.PositionAndRotation |
Feature.ImageTracking |
Feature.PlaneTracking |
Feature.ObjectTracking |
Feature.EnvironmentProbes,
// Rank is meant to be used as a tie breaker in our implementation of ChooseConfiguration, but since we will
// always choose this descriptor, it doesn't matter what value we use here.
0);
// Rank is meant to be used as a tie breaker in our implementation of ChooseConfiguration, but since we will
// always choose this descriptor, it doesn't matter what value we use here.
0);
public override Configuration ChooseConfiguration(NativeSlice<ConfigurationDescriptor> descriptors, Feature requestedFeatures)
{
// If location services are running, then we can request an ARGeoTrackingConfiguration by its class pointer
return Input.location.status == LocationServiceStatus.Running
? new Configuration(s_ARGeoConfigurationDescriptor, requestedFeatures.Intersection(s_ARGeoConfigurationDescriptor.capabilities))
: s_DefaultChooser.ChooseConfiguration(descriptors, requestedFeatures);
}
public override Configuration ChooseConfiguration(NativeSlice<ConfigurationDescriptor> descriptors, Feature requestedFeatures)
{
// If location services are running, then we can request an ARGeoTrackingConfiguration by its class pointer
return Input.location.status == LocationServiceStatus.Running
? new Configuration(s_ARGeoConfigurationDescriptor, requestedFeatures.Intersection(s_ARGeoConfigurationDescriptor.capabilities))
: s_DefaultChooser.ChooseConfiguration(descriptors, requestedFeatures);
}
public static extern IntPtr ARGeoTrackingConfigurationClass
{
[DllImport("__Internal", EntryPoint = "ARGeoTrackingConfiguration_class")]
get;
public static extern IntPtr ARGeoTrackingConfigurationClass
{
[DllImport("__Internal", EntryPoint = "ARGeoTrackingConfiguration_class")]
get;
}
}
[RequireComponent(typeof(ARSession))]
public class EnableGeoAnchors : MonoBehaviour
{
#if UNITY_IOS// && !UNITY_EDITOR
// See https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.0/manual/extensions.html
public struct NativePtrData
{
public int version;
public IntPtr sessionPtr;
}
// See https://developer.apple.com/documentation/corelocation/cllocationcoordinate2d?language=objc
public struct CLLocationCoordinate2D
{
public double latitude;
public double longitude;
}
// ARGeoAnchors requires location services
void Start() => Input.location.Start();
void OnGUI()
[RequireComponent(typeof(ARSession))]
public class EnableGeoAnchors : MonoBehaviour
GUI.skin.label.fontSize = 50;
GUILayout.Space(100);
#if UNITY_IOS && !UNITY_EDITOR
public static bool IsSupported => ARGeoAnchorConfigurationChooser.ARGeoTrackingConfigurationClass != IntPtr.Zero;
if (ARGeoAnchorConfigurationChooser.ARGeoTrackingConfigurationClass == IntPtr.Zero)
// See https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.0/manual/extensions.html
public struct NativePtrData
GUILayout.Label("ARGeoTrackingConfiguration is not supported on this device.");
return;
public int version;
public IntPtr sessionPtr;
switch (Input.location.status)
// See https://developer.apple.com/documentation/corelocation/cllocationcoordinate2d?language=objc
public struct CLLocationCoordinate2D
case LocationServiceStatus.Initializing:
GUILayout.Label("Waiting for location services...");
break;
case LocationServiceStatus.Stopped:
GUILayout.Label("Location services stopped. Unable to use geo anchors.");
break;
case LocationServiceStatus.Failed:
GUILayout.Label("Location services failed. Unable to use geo anchors.");
break;
case LocationServiceStatus.Running:
GUILayout.Label("Tap screen to add a geo anchor.");
break;
public double latitude;
public double longitude;
}
void Update()
{
// Can't do anything interesting until location services are running.
if (Input.location.status != LocationServiceStatus.Running)
return;
// ARGeoAnchors requires location services
void Start() => Input.location.Start();
if (GetComponent<ARSession>().subsystem is ARKitSessionSubsystem subsystem)
void OnGUI()
if (!(subsystem.configurationChooser is ARGeoAnchorConfigurationChooser))
GUI.skin.label.fontSize = 50;
GUILayout.Space(100);
if (ARGeoAnchorConfigurationChooser.ARGeoTrackingConfigurationClass == IntPtr.Zero)
// Replace the config chooser with our own
subsystem.configurationChooser = new ARGeoAnchorConfigurationChooser();
GUILayout.Label("ARGeoTrackingConfiguration is not supported on this device.");
return;
// We don't have to do this, but it will silence a warning message in Xcode
// since the ARGeoTrackingConfiguration can only use the GravityAndHeading value.
subsystem.requestedWorldAlignment = ARWorldAlignment.GravityAndHeading;
switch (Input.location.status)
{
case LocationServiceStatus.Initializing:
GUILayout.Label("Waiting for location services...");
break;
case LocationServiceStatus.Stopped:
GUILayout.Label("Location services stopped. Unable to use geo anchors.");
break;
case LocationServiceStatus.Failed:
GUILayout.Label("Location services failed. Unable to use geo anchors.");
break;
case LocationServiceStatus.Running:
GUILayout.Label("Tap screen to add a geo anchor.");
break;
}
}
// Make sure we have a native ptr
if (subsystem.nativePtr == IntPtr.Zero)
void Update()
{
// Can't do anything interesting until location services are running.
if (Input.location.status != LocationServiceStatus.Running)
// Get the session ptr from the native ptr data
var session = Marshal.PtrToStructure<NativePtrData>(subsystem.nativePtr).sessionPtr;
if (session == IntPtr.Zero)
return;
if (GetComponent<ARSession>().subsystem is ARKitSessionSubsystem subsystem)
{
if (!(subsystem.configurationChooser is ARGeoAnchorConfigurationChooser))
{
// Replace the config chooser with our own
subsystem.configurationChooser = new ARGeoAnchorConfigurationChooser();
}
var screenTapped = Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended;
if (screenTapped)
{
// Get last known location data
var locationData = Input.location.lastData;
// We don't have to do this, but it will silence a warning message in Xcode
// since the ARGeoTrackingConfiguration can only use the GravityAndHeading value.
subsystem.requestedWorldAlignment = ARWorldAlignment.GravityAndHeading;
// Add a geo anchor. See GeoAnchorsNativeInterop.m to see how this works.
AddGeoAnchor(session, new CLLocationCoordinate2D
// Make sure we have a native ptr
if (subsystem.nativePtr == IntPtr.Zero)
return;
// Get the session ptr from the native ptr data
var session = Marshal.PtrToStructure<NativePtrData>(subsystem.nativePtr).sessionPtr;
if (session == IntPtr.Zero)
return;
var screenTapped = Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended;
if (screenTapped)
latitude = locationData.latitude,
longitude = locationData.longitude
}, locationData.altitude);
}
// Get last known location data
var locationData = Input.location.lastData;
DoSomethingWithSession(session);
// Add a geo anchor. See GeoAnchorsNativeInterop.m to see how this works.
AddGeoAnchor(session, new CLLocationCoordinate2D
{
latitude = locationData.latitude,
longitude = locationData.longitude
}, locationData.altitude);
}
DoSomethingWithSession(session);
}
}
[DllImport("__Internal")]
static extern void DoSomethingWithSession(IntPtr session);
[DllImport("__Internal")]
static extern void DoSomethingWithSession(IntPtr session);
[DllImport("__Internal", EntryPoint = "ARSession_addGeoAnchor")]
static extern void AddGeoAnchor(IntPtr session, CLLocationCoordinate2D coordinate, double altitude);
[DllImport("__Internal", EntryPoint = "ARSession_addGeoAnchor")]
static extern void AddGeoAnchor(IntPtr session, CLLocationCoordinate2D coordinate, double altitude);
#else
public static bool IsSupported => false;
}
}

9
Assets/Scripts/UX/CheckAvailableFeatures.cs


m_ARWorldMap.interactable = true;
}
if (sessionDescriptors.Count > 0 && IsiOS14OrLater())
if (sessionDescriptors.Count > 0 && EnableGeoAnchors.IsSupported)
{
m_ARKitGeoAnchors.interactable = true;
}

m_ThermalStateButton.interactable = true;
#endif // UNITY_IOS
}
#if UNITY_IOS && !UNITY_EDITOR
[DllImport("__Internal", EntryPoint = "ARFoundationSamples_IsiOS14OrLater")]
static extern bool IsiOS14OrLater();
#else
static bool IsiOS14OrLater() => false;
#endif
}
}

8
Packages/manifest.json


"com.unity.ide.vscode": "1.2.3",
"com.unity.inputsystem": "1.0.0",
"com.unity.ugui": "1.0.0",
"com.unity.xr.arcore": "4.1.0-preview.13",
"com.unity.xr.arfoundation": "4.1.0-preview.13",
"com.unity.xr.arkit": "4.1.0-preview.13",
"com.unity.xr.arkit-face-tracking": "4.1.0-preview.13",
"com.unity.xr.arcore": "4.1.1",
"com.unity.xr.arfoundation": "4.1.1",
"com.unity.xr.arkit": "4.1.1",
"com.unity.xr.arkit-face-tracking": "4.1.1",
"com.unity.xr.interaction.toolkit": "0.10.0-preview.7",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",

4
ProjectSettings/ProjectVersion.txt


m_EditorVersion: 2020.1.12f1
m_EditorVersionWithRevision: 2020.1.12f1 (55b56f0a86e3)
m_EditorVersion: 2020.1.13f1
m_EditorVersionWithRevision: 2020.1.13f1 (5e24f28bfbc0)

2
README.md


| 2018.4 | [1.5 (preview)](https://github.com/Unity-Technologies/arfoundation-samples/tree/1.5-preview) |
| 2019.3 | [2.1 (verified)](https://github.com/Unity-Technologies/arfoundation-samples/tree/2.1) |
| 2020.1 | 3.0 (verified) |
| 2020.2 | 4.1 (preview) |
| 2020.2 | 4.1 (verified) |
## ARSubsystems

410
Packages/packages-lock.json


{
"dependencies": {
"com.unity.editorcoroutines": {
"version": "1.0.0",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.ext.nunit": {
"version": "1.0.0",
"depth": 2,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.ide.rider": {
"version": "1.2.1",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.test-framework": "1.1.1"
},
"url": "https://packages.unity.com"
},
"com.unity.ide.visualstudio": {
"version": "2.0.5",
"depth": 0,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.ide.vscode": {
"version": "1.2.3",
"depth": 0,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.inputsystem": {
"version": "1.0.0",
"depth": 0,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.subsystemregistration": {
"version": "1.1.0",
"depth": 2,
"source": "registry",
"dependencies": {
"com.unity.modules.subsystems": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.test-framework": {
"version": "1.1.18",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.ext.nunit": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.ugui": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.imgui": "1.0.0"
}
},
"com.unity.xr.arcore": {
"version": "4.1.0-preview.13",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.xr.arsubsystems": "4.1.0-preview.13",
"com.unity.xr.management": "3.2.16",
"com.unity.modules.androidjni": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.xr.arfoundation": {
"version": "4.1.0-preview.13",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.xr.arsubsystems": "4.1.0-preview.13",
"com.unity.xr.management": "3.2.16"
},
"url": "https://packages.unity.com"
},
"com.unity.xr.arkit": {
"version": "4.1.0-preview.13",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.editorcoroutines": "1.0.0",
"com.unity.xr.arsubsystems": "4.1.0-preview.13",
"com.unity.xr.management": "3.2.16"
},
"url": "https://packages.unity.com"
},
"com.unity.xr.arkit-face-tracking": {
"version": "4.1.0-preview.13",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.xr.arkit": "4.1.0-preview.13",
"com.unity.xr.arsubsystems": "4.1.0-preview.13"
},
"url": "https://packages.unity.com"
},
"com.unity.xr.arsubsystems": {
"version": "4.1.0-preview.13",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.subsystemregistration": "1.1.0"
},
"url": "https://packages.unity.com"
},
"com.unity.xr.interaction.toolkit": {
"version": "0.10.0-preview.7",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.inputsystem": "1.0.0",
"com.unity.ugui": "1.0.0",
"com.unity.xr.legacyinputhelpers": "2.1.4"
},
"url": "https://packages.unity.com"
},
"com.unity.xr.legacyinputhelpers": {
"version": "2.1.4",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.xr.management": {
"version": "3.2.16",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.xr.legacyinputhelpers": "2.1.2",
"com.unity.subsystemregistration": "1.0.6"
},
"url": "https://packages.unity.com"
},
"com.unity.modules.ai": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.androidjni": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.animation": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.assetbundle": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.audio": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.cloth": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.physics": "1.0.0"
}
},
"com.unity.modules.director": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.animation": "1.0.0"
}
},
"com.unity.modules.imageconversion": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.imgui": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.jsonserialize": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.particlesystem": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.physics": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.physics2d": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.screencapture": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.imageconversion": "1.0.0"
}
},
"com.unity.modules.subsystems": {
"version": "1.0.0",
"depth": 1,
"source": "builtin",
"dependencies": {
"com.unity.modules.jsonserialize": "1.0.0"
}
},
"com.unity.modules.terrain": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.terrainphysics": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.terrain": "1.0.0"
}
},
"com.unity.modules.tilemap": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.physics2d": "1.0.0"
}
},
"com.unity.modules.ui": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.uielements": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.uielementsnative": "1.0.0"
}
},
"com.unity.modules.uielementsnative": {
"version": "1.0.0",
"depth": 1,
"source": "builtin",
"dependencies": {
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
}
},
"com.unity.modules.umbra": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.unityanalytics": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
}
},
"com.unity.modules.unitywebrequest": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.unitywebrequestassetbundle": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.assetbundle": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0"
}
},
"com.unity.modules.unitywebrequestaudio": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.audio": "1.0.0"
}
},
"com.unity.modules.unitywebrequesttexture": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.imageconversion": "1.0.0"
}
},
"com.unity.modules.unitywebrequestwww": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
"com.unity.modules.unitywebrequestaudio": "1.0.0",
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.assetbundle": "1.0.0",
"com.unity.modules.imageconversion": "1.0.0"
}
},
"com.unity.modules.vehicles": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.physics": "1.0.0"
}
},
"com.unity.modules.video": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0"
}
},
"com.unity.modules.vr": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.xr": "1.0.0"
}
},
"com.unity.modules.wind": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.xr": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.subsystems": "1.0.0"
}
}
}
}
正在加载...
取消
保存