浏览代码

Updating for AR Foundation 4.1.0-preview.12.

/4.1
Todd Stinson 4 年前
当前提交
252ea895
共有 43 个文件被更改,包括 1763 次插入96 次删除
  1. 1
      .gitignore
  2. 234
      Assets/Scenes/ARFoundationMenu/Menu.unity
  3. 10
      Assets/Scenes/CameraGrain/CameraGrain.shader
  4. 44
      Assets/Scenes/ImageTracking/Prefabs/FireFliesPrefab/Shaders/FireFly.shader
  5. 11
      Assets/Scenes/Meshing/Shaders/MeshingOverlay.shader
  6. 11
      Assets/Scenes/PlaneOcclusion/PlaneOcclusionShader.shader
  7. 5
      Assets/Scripts/UX/ARSceneSelectUI.cs
  8. 22
      Assets/Scripts/UX/CheckAvailableFeatures.cs
  9. 11
      Assets/Shaders/DepthGradient.shader
  10. 133
      Assets/Shaders/FeatheredPlaneShader.shader
  11. 11
      Assets/Shaders/HumanStencil.shader
  12. 11
      Assets/Shaders/Normal.shader
  13. 11
      Assets/Shaders/NormalOverlay.shader
  14. 15
      Packages/manifest.json
  15. 15
      ProjectSettings/EditorBuildSettings.asset
  16. 3
      ProjectSettings/ProjectSettings.asset
  17. 4
      ProjectSettings/ProjectVersion.txt
  18. 14
      README.md
  19. 3
      Assets/Scenes/ARKit/ARKitCoachingOverlay/ARKitCoachingOverlay.cs
  20. 95
      Assets/Scenes/ARKit/ARKitCoachingOverlay/ARKitCoachingOverlay.unity
  21. 8
      Assets/Scenes/ARKit.meta
  22. 409
      Packages/packages-lock.json
  23. 8
      Assets/Scenes/ARKit/ARKitGeoAnchors.meta
  24. 454
      Assets/Scenes/ARKit/ARKitGeoAnchors/ARKitGeoAnchors.unity
  25. 7
      Assets/Scenes/ARKit/ARKitGeoAnchors/ARKitGeoAnchors.unity.meta
  26. 153
      Assets/Scenes/ARKit/ARKitGeoAnchors/EnableGeoAnchors.cs
  27. 11
      Assets/Scenes/ARKit/ARKitGeoAnchors/EnableGeoAnchors.cs.meta
  28. 78
      Assets/Scenes/ARKit/ARKitGeoAnchors/GeoAnchorsNativeInterop.m
  29. 37
      Assets/Scenes/ARKit/ARKitGeoAnchors/GeoAnchorsNativeInterop.m.meta
  30. 19
      Assets/Scenes/ARKit/ARKitCoachingOverlay/CustomSessionDelegate.cs
  31. 11
      Assets/Scenes/ARKit/ARKitCoachingOverlay/CustomSessionDelegate.cs.meta
  32. 0
      /Assets/Scenes/ARKit/ARWorldMap.unity
  33. 0
      /Assets/Scenes/ARKit/ARWorldMap.unity.meta
  34. 0
      /Assets/Scenes/ARKit/ARCollaborationData.meta
  35. 0
      /Assets/Scenes/ARKit/ARKitCoachingOverlay.meta
  36. 0
      /Assets/Scenes/ARKit/ARKitCoachingOverlay
  37. 0
      /Assets/Scenes/ARKit/ARWorldMapSettings.lighting
  38. 0
      /Assets/Scenes/ARKit/ARWorldMapSettings.lighting.meta
  39. 0
      /Assets/Scenes/ARKit/ThermalState.meta
  40. 0
      /Assets/Scenes/ARKit/ThermalState
  41. 0
      /Assets/Scenes/ARKit/ARCollaborationData

1
.gitignore


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

234
Assets/Scenes/ARFoundationMenu/Menu.unity


m_ImageTracking: {fileID: 1311724826}
m_Anchors: {fileID: 1905833466}
m_ARWorldMap: {fileID: 1817576787}
m_ARKitGeoAnchors: {fileID: 1604105016}
m_CpuImages: {fileID: 340560480}
m_EnvironmentProbes: {fileID: 1761617832}
m_ARCollaborationData: {fileID: 1385680569}

m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontSize: 12
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10

m_TargetGraphic: {fileID: 1141134466}
m_HandleRect: {fileID: 1141134465}
m_Direction: 0
m_Value: 0
m_Value: 1
m_Size: 1
m_NumberOfSteps: 0
m_OnValueChanged:

- {fileID: 2011106399}
- {fileID: 1726760292}
- {fileID: 1831158601}
- {fileID: 1604105014}
m_Father: {fileID: 1413559114}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1604105013
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1604105014}
- component: {fileID: 1604105018}
- component: {fileID: 1604105017}
- component: {fileID: 1604105016}
- component: {fileID: 1604105015}
m_Layer: 5
m_Name: ARKitGeoAnchors
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1604105014
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1604105013}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 2.8958, y: 2.8958, z: 2.8958}
m_Children:
- {fileID: 1644178724}
m_Father: {fileID: 1569808631}
m_RootOrder: 24
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -350, y: -775}
m_SizeDelta: {x: 110, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1604105015
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1604105013}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 16733cd6749cf4d96be9df0329c6938a, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Tooltip: {fileID: 2094799242}
--- !u!114 &1604105016
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1604105013}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 0
m_TargetGraphic: {fileID: 1604105017}
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 774532498}
m_TargetAssemblyTypeName: UnityEngine.XR.ARFoundation.Samples.ARSceneSelectUI,
Assembly-CSharp
m_MethodName: ARKitGeoAnchorsButtonPressed
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!114 &1604105017
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1604105013}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &1604105018
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1604105013}
m_CullTransparentMesh: 0
--- !u!1 &1644178723
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1644178724}
- component: {fileID: 1644178726}
- component: {fileID: 1644178725}
m_Layer: 5
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1644178724
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1644178723}
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: 1604105014}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1644178725
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1644178723}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Geo Anchors
--- !u!222 &1644178726
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1644178723}
m_CullTransparentMesh: 0
--- !u!1 &1704130875
GameObject:
m_ObjectHideFlags: 0

m_HandleRect: {fileID: 1130901185}
m_Direction: 2
m_Value: 1
m_Size: 0.33929503
m_Size: 0.19074301
m_NumberOfSteps: 0
m_OnValueChanged:
m_PersistentCalls:

10
Assets/Scenes/CameraGrain/CameraGrain.shader


{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f

float4 screenPos : TEXCOORD1;
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;

v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
o.screenPos = ComputeScreenPos(o.vertex);

fixed4 frag (v2f i) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float scale = 3;
float2 nuv = scale * (i.screenPos.xy/i.screenPos.w);
nuv.xy += float2(sin(_Time.y * _NoiseSpeed.x), cos(_Time.y * _NoiseSpeed.y));

44
Assets/Scenes/ImageTracking/Prefabs/FireFliesPrefab/Shaders/FireFly.shader


CGPROGRAM
#pragma vertex vert alpha:fade
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata

float4 color : COLOR;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f

float4 color : COLOR;
UNITY_VERTEX_OUTPUT_STEREO
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
clip(i.color.a - 0.5);
col += emissive * pow(_EmissiveAmount, 2.2);

#pragma vertex vert
#pragma fragment frag
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f

float4 color : COLOR;
UNITY_VERTEX_OUTPUT_STEREO
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
fixed4 wings = tex2D(_Wings, i.uv.zw);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
fixed4 wings = tex2D(_Wings, i.uv.zw);
}
}
}

11
Assets/Scenes/Meshing/Shaders/MeshingOverlay.shader


struct appdata
{
float3 position : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
struct fragment_output

v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
// Transform the position from object space to clip space.
o.position = UnityObjectToClipPos(v.position);;
return o;

fragment_output frag (v2f i)
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
fragment_output o;
o.color = _Color;
return o;

11
Assets/Scenes/PlaneOcclusion/PlaneOcclusionShader.shader


struct appdata
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.vertex = UnityObjectToClipPos(v.vertex);
return o;
}

UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
return fixed4(0.0, 0.0, 0.0, 0.0);
}
ENDCG

5
Assets/Scripts/UX/ARSceneSelectUI.cs


LoadScene("ARWorldMap");
}
public void ARKitGeoAnchorsButtonPressed()
{
LoadScene("ARKitGeoAnchors");
}
public void CpuImagesButtonPressed()
{
LoadScene("CpuImages");

22
Assets/Scripts/UX/CheckAvailableFeatures.cs


using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.XR.ARSubsystems;

{
get => m_ARWorldMap;
set => m_ARWorldMap = value;
}
[SerializeField]
Button m_ARKitGeoAnchors;
public Button ARKitGeoAnchors
{
get => m_ARKitGeoAnchors;
set => m_ARKitGeoAnchors = value;
}
[SerializeField]

m_ARWorldMap.interactable = true;
}
if (sessionDescriptors.Count > 0 && IsiOS14OrLater())
{
m_ARKitGeoAnchors.interactable = true;
}
if(planeDescriptors.Count > 0 && rayCastDescriptors.Count > 0 && participantDescriptors.Count > 0 && ARKitSessionSubsystem.supportsCollaboration)
{
m_ARCollaborationData.interactable = true;

#if UNITY_IOS
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
}
}

11
Assets/Shaders/DepthGradient.shader


{
float3 position : POSITION;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f

UNITY_VERTEX_OUTPUT_STEREO
};
struct fragment_output

v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.position = TransformObjectToHClip(v.position);
o.texcoord = mul(float3(v.texcoord, 1.0f), _DisplayRotationPerFrame).xy;
return o;

fragment_output frag (v2f i)
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
// Sample the environment depth (in meters).
float envDistance = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord).r;

133
Assets/Shaders/FeatheredPlaneShader.shader


Shader "Unlit/FeatheredPlaneShader"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_TexTintColor("Texture Tint Color", Color) = (1,1,1,1)
_PlaneColor("Plane Color", Color) = (1,1,1,1)
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
LOD 100
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_TexTintColor("Texture Tint Color", Color) = (1,1,1,1)
_PlaneColor("Plane Color", Color) = (1,1,1,1)
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
LOD 100
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
float3 uv2 : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
float3 uv2 : TEXCOORD1;
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
float4 _MainTex_ST;
fixed4 _TexTintColor;
fixed4 _PlaneColor;
float _ShortestUVMapping;
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
v2f vert (appdata v)
{
v2f o;
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
float3 uv2 : TEXCOORD1;
};
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
struct v2f
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
float3 uv2 : TEXCOORD1;
};
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
o.uv2 = v.uv2;
return o;
}
sampler2D _MainTex;
float4 _MainTex_ST;
fixed4 _TexTintColor;
fixed4 _PlaneColor;
float _ShortestUVMapping;
fixed4 frag (v2f i) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
o.uv2 = v.uv2;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv) * _TexTintColor;
col = lerp( _PlaneColor, col, col.a);
// Fade out from as we pass the edge.
// uv2.x stores a mapped UV that will be "1" at the beginning of the feathering.
// We fade until we reach at the edge of the shortest UV mapping.
// This is the remmaped UV value at the vertex.
// We choose the shorted one so that ll edges will fade out completely.
// See ARFeatheredPlaneMeshVisualizer.cs for more details.
col.a *= 1-smoothstep(1, _ShortestUVMapping, i.uv2.x);
return col;
}
ENDCG
}
}
fixed4 col = tex2D(_MainTex, i.uv) * _TexTintColor;
col = lerp( _PlaneColor, col, col.a);
// Fade out from as we pass the edge.
// uv2.x stores a mapped UV that will be "1" at the beginning of the feathering.
// We fade until we reach at the edge of the shortest UV mapping.
// This is the remmaped UV value at the vertex.
// We choose the shorted one so that ll edges will fade out completely.
// See ARFeatheredPlaneMeshVisualizer.cs for more details.
col.a *= 1-smoothstep(1, _ShortestUVMapping, i.uv2.x);
return col;
}
ENDCG
}
}
}

11
Assets/Shaders/HumanStencil.shader


{
float3 position : POSITION;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f

UNITY_VERTEX_OUTPUT_STEREO
};
struct fragment_output

v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.position = TransformObjectToHClip(v.position);
o.texcoord = mul(float3(v.texcoord, 1.0f), _DisplayRotationPerFrame).xy;
return o;

fragment_output frag (v2f i)
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float stencilValue = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord).r;
fragment_output o;

11
Assets/Shaders/Normal.shader


{
float3 position : POSITION;
float3 normal : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f

UNITY_VERTEX_OUTPUT_STEREO
};
struct fragment_output

v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.position = UnityObjectToClipPos(v.position);
o.worldNormal = UnityObjectToWorldNormal(v.normal);
return o;

fragment_output frag (v2f i)
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
fragment_output o;
o.color.xyz = i.worldNormal * 0.5f + 0.5f;
o.color.w = 1.0h;

11
Assets/Shaders/NormalOverlay.shader


{
float3 position : POSITION;
float3 normal : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f

UNITY_VERTEX_OUTPUT_STEREO
};
struct fragment_output

v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.position = UnityObjectToClipPos(v.position);
o.worldNormal = UnityObjectToWorldNormal(v.normal);
return o;

fragment_output frag (v2f i)
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
fragment_output o;
o.color.xyz = i.worldNormal * 0.5f + 0.5f;
o.color.w = _Transparency;

15
Packages/manifest.json


"dependencies": {
"com.unity.ide.rider": "1.2.1",
"com.unity.ide.visualstudio": "2.0.3",
"com.unity.ide.vscode": "1.2.2",
"com.unity.ide.vscode": "1.2.3",
"com.unity.xr.arcore": "4.1.0-preview.11",
"com.unity.xr.arfoundation": "4.1.0-preview.11",
"com.unity.xr.arkit": "4.1.0-preview.11",
"com.unity.xr.arkit-face-tracking": "4.1.0-preview.11",
"com.unity.xr.arcore": "4.1.0-preview.12",
"com.unity.xr.arfoundation": "4.1.0-preview.12",
"com.unity.xr.arkit": "4.1.0-preview.12",
"com.unity.xr.arkit-face-tracking": "4.1.0-preview.12",
"com.unity.xr.interaction.toolkit": "0.9.4-preview",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",

"com.unity.modules.vr": "1.0.0",
"com.unity.modules.wind": "1.0.0",
"com.unity.modules.xr": "1.0.0"
}
}
},
"scopedRegistries": []
}

15
ProjectSettings/EditorBuildSettings.asset


path: Assets/Scenes/ARFoundationMenu/Menu.unity
guid: 904110ab8cef14f7d96c56ca20774e5a
- enabled: 1
path: Assets/Scenes/ARCollaborationData/ARCollaborationDataExample.unity
path: Assets/Scenes/ARKit/ARCollaborationData/ARCollaborationDataExample.unity
path: Assets/Scenes/ARKitCoachingOverlay/ARKitCoachingOverlay.unity
path: Assets/Scenes/ARKit/ARKitCoachingOverlay/ARKitCoachingOverlay.unity
path: Assets/Scenes/ARWorldMap.unity
path: Assets/Scenes/ARKit/ARKitGeoAnchors/ARKitGeoAnchors.unity
guid: 338f0f26e48a9442c8562245d8bae9ab
- enabled: 1
path: Assets/Scenes/ARKit/ARWorldMap.unity
- enabled: 1
path: Assets/Scenes/ARKit/ThermalState/ThermalState.unity
guid: e5b0cb11dfe354e67a344c280bf8b611
- enabled: 1
path: Assets/Scenes/Anchors.unity
guid: 5cba9114a192a46a7aef31da62316e39

- enabled: 1
path: Assets/Scenes/SimpleAR/SimpleAR.unity
guid: 99c9720ab356a0642a771bea13969a05
- enabled: 1
path: Assets/Scenes/ThermalState/ThermalState.unity
guid: e5b0cb11dfe354e67a344c280bf8b611
m_configObjects:
UnityEditor.XR.ARCore.ARCoreSettings: {fileID: 11400000, guid: f8ce26fe3bc69499b9be4b2378e97a94,
type: 2}

3
ProjectSettings/ProjectSettings.asset


logObjCUncaughtExceptions: 1
enableCrashReportAPI: 0
cameraUsageDescription: Camera required for AR
locationUsageDescription:
locationUsageDescription: Required for Geo Anchors
microphoneUsageDescription:
switchNMETAOverride:
switchNetLibKey:

il2cppCompilerConfiguration: {}
managedStrippingLevel: {}
incrementalIl2cppBuild: {}
suppressCommonWarnings: 1
allowUnsafeCode: 1
useDeterministicCompilation: 1
additionalIl2CppArgs:

4
ProjectSettings/ProjectVersion.txt


m_EditorVersion: 2020.1.10f1
m_EditorVersionWithRevision: 2020.1.10f1 (974a9d56f159)
m_EditorVersion: 2020.1.11f1
m_EditorVersionWithRevision: 2020.1.11f1 (698c1113cef0)

14
README.md


This script can create two kinds of anchors:
1. If a feature point is hit, it creates a normal anchor at the hit pose using the [AddAnchor](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.0/api/UnityEngine.XR.ARFoundation.ARAnchorManager.html#UnityEngine_XR_ARFoundation_ARAnchorManager_AddAnchor_UnityEngine_Pose_) method.
1. If a plane is hit, it creates an anchor "attached" to the plane using the [AttachAnchor](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.0/api/UnityEngine.XR.ARFoundation.ARAnchorManager.html#UnityEngine_XR_ARFoundation_ARAnchorManager_AttachAnchor_UnityEngine_XR_ARFoundation_ARPlane_UnityEngine_Pose_) method.
1. If a plane is hit, it creates an anchor "attached" to the plane using the [AttachAnchor](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.0/api/UnityEngine.XR.ARFoundation.ARAnchorManager.html#UnityEngine_XR_ARFoundation_ARAnchorManager_AttachAnchor_UnityEngine_XR_ARFoundation_ARPlane_UnityEngine_Pose_) method.
## Scale

The coaching overlay can be activated automatically or manually, and you can set its goal. In this sample, we've set the goal to be "Any plane", and for it to activate automatically. This will display a special UI on the screen until a plane is found. There is also a button to activate it manually.
The sample includes a MonoBehavior to define the settings of the coaching overlay. See [`ARKitCoachingOverlay.cs`](https://github.com/Unity-Technologies/arfoundation-samples/blob/master/Assets/Scenes/ARKitCoachingOverlay/ARKitCoachingOverlay.cs).
The sample includes a MonoBehavior to define the settings of the coaching overlay. See [`ARKitCoachingOverlay.cs`](https://github.com/Unity-Technologies/arfoundation-samples/blob/master/Assets/Scenes/ARKit/ARKitCoachingOverlay/ARKitCoachingOverlay.cs).
This sample also shows how to subscribe to ARKit session callbacks. See [CustomSessionDelegate](https://github.com/Unity-Technologies/arfoundation-samples/blob/master/Assets/Scenes/ARKit/ARKitCoachingOverlay/CustomSessionDelegate.cs)
## ARKitGeoAnchors
[ARKit's ARGeoAnchors](https://developer.apple.com/documentation/arkit/argeoanchor?language=objc) are not yet supported by ARFoundation, but you can still access this feature with a bit of Objective-C. This sample uses a custom [ConfigurationChooser](https://docs.unity3d.com/Packages/com.unity.xr.arsubsystems@4.1/api/UnityEngine.XR.ARSubsystems.ConfigurationChooser.html) to instruct the ARKit XR Plugin to use an [ARGeoTrackingConfiguration](https://developer.apple.com/documentation/arkit/argeotrackingconfiguration?language=objc).
This sample also shows how to interpret the [nativePtr](https://docs.unity3d.com/Packages/com.unity.xr.arsubsystems@4.1/api/UnityEngine.XR.ARSubsystems.XRSessionSubsystem.html#UnityEngine_XR_ARSubsystems_XRSessionSubsystem_nativePtr) provided by the [XRSessionSubsystem](https://docs.unity3d.com/Packages/com.unity.xr.arsubsystems@4.1/api/UnityEngine.XR.ARSubsystems.XRSessionSubsystem.html) as an ARKit [ARSession](https://developer.apple.com/documentation/arkit/arsession?language=objc) pointer.
This sample requires an iOS device running iOS 14.0 or later, an A12 chip or later, location services enabled, and cellular capability.
## ImageTracking

3
Assets/Scenes/ARKit/ARKitCoachingOverlay/ARKitCoachingOverlay.cs


{
sessionSubsystem.requestedCoachingGoal = (ARCoachingGoal)m_Goal;
sessionSubsystem.coachingActivatesAutomatically = m_ActivatesAutomatically;
sessionSubsystem.sessionDelegate = new CustomSessionDelegate();
}
else
#endif

}
}
}
}
}

95
Assets/Scenes/ARKit/ARKitCoachingOverlay/ARKitCoachingOverlay.unity


- {fileID: 791307474}
- {fileID: 339984496}
- {fileID: 1550884487}
- {fileID: 1326615953}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

- component: {fileID: 860547060}
- component: {fileID: 860547059}
- component: {fileID: 860547062}
- component: {fileID: 860547063}
m_Layer: 0
m_Name: AR Session
m_TagString: Untagged

m_EditorClassIdentifier:
m_Goal: 3
m_ActivatesAutomatically: 0
--- !u!114 &860547063
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 860547058}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6b9ec441ecd1d4c21b5736659749bcf2, type: 3}
m_Name:
m_EditorClassIdentifier:
m_LogText: {fileID: 1326615954}
m_VisibleMessageCount: 40
--- !u!1 &1270793018
GameObject:
m_ObjectHideFlags: 0

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1309688135}
m_CullTransparentMesh: 0
--- !u!1 &1326615952
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1326615953}
- component: {fileID: 1326615955}
- component: {fileID: 1326615954}
m_Layer: 5
m_Name: Log
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1326615953
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1326615952}
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: 767025049}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 0, y: -100}
m_SizeDelta: {x: 800, y: 600}
m_Pivot: {x: 0, y: 1}
--- !u!114 &1326615954
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1326615952}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 30
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 3
m_MaxSize: 40
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text:
--- !u!222 &1326615955
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1326615952}
m_CullTransparentMesh: 0
--- !u!1 &1550884486
GameObject:

8
Assets/Scenes/ARKit.meta


fileFormatVersion: 2
guid: 2e0dd4061c8b44f6685dbb181356cb71
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

409
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.3",
"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.12",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.xr.arsubsystems": "4.1.0-preview.12",
"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.12",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.xr.arsubsystems": "4.1.0-preview.12",
"com.unity.xr.management": "3.2.16"
},
"url": "https://packages.unity.com"
},
"com.unity.xr.arkit": {
"version": "4.1.0-preview.12",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.editorcoroutines": "1.0.0",
"com.unity.xr.arsubsystems": "4.1.0-preview.12",
"com.unity.xr.management": "3.2.16"
},
"url": "https://packages.unity.com"
},
"com.unity.xr.arkit-face-tracking": {
"version": "4.1.0-preview.12",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.xr.arkit": "4.1.0-preview.12",
"com.unity.xr.arsubsystems": "4.1.0-preview.12"
},
"url": "https://packages.unity.com"
},
"com.unity.xr.arsubsystems": {
"version": "4.1.0-preview.12",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.subsystemregistration": "1.1.0"
},
"url": "https://packages.unity.com"
},
"com.unity.xr.interaction.toolkit": {
"version": "0.9.4-preview",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.ugui": "1.0.0",
"com.unity.xr.legacyinputhelpers": "1.3.11"
},
"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"
}
}
}
}

8
Assets/Scenes/ARKit/ARKitGeoAnchors.meta


fileFormatVersion: 2
guid: e6deb90c0c9ab4a1c8a0e761b3e0b790
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

454
Assets/Scenes/ARKit/ARKitGeoAnchors/ARKitGeoAnchors.unity


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &277780414
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 277780416}
- component: {fileID: 277780415}
m_Layer: 0
m_Name: AR Session Origin
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &277780415
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 277780414}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 520bb47c46cf8624fafb307b7d1b862a, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Camera: {fileID: 1198095226}
--- !u!4 &277780416
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 277780414}
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:
- {fileID: 1198095230}
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &793213725
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 793213728}
- component: {fileID: 793213727}
- component: {fileID: 793213726}
- component: {fileID: 793213729}
m_Layer: 0
m_Name: AR Session
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &793213726
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 793213725}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fa850fbd5b8aded44846f96e35f1a9f5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &793213727
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 793213725}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3859a92a05d4f5d418cb6ca605290e74, type: 3}
m_Name:
m_EditorClassIdentifier:
m_AttemptUpdate: 1
m_MatchFrameRate: 1
m_TrackingMode: 2
--- !u!4 &793213728
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 793213725}
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: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &793213729
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 793213725}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 83ef5ba9cc0da4a19a969308a48e993d, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1198095225
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1198095230}
- component: {fileID: 1198095226}
- component: {fileID: 1198095229}
- component: {fileID: 1198095228}
- component: {fileID: 1198095227}
m_Layer: 0
m_Name: AR Camera
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!20 &1198095226
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1198095225}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 2
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.1
far clip plane: 20
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!114 &1198095227
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1198095225}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 816b289ef451e094f9ae174fb4cf8db0, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UseCustomMaterial: 0
m_CustomMaterial: {fileID: 0}
--- !u!114 &1198095228
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1198095225}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4966719baa26e4b0e8231a24d9bd491a, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FocusMode: -1
m_LightEstimationMode: -1
m_AutoFocus: 1
m_LightEstimation: 0
m_FacingDirection: 1
--- !u!114 &1198095229
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1198095225}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6e3c44306fb1e439a9f18b2212b8ab70, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1198095230
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1198095225}
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: 277780416}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1494310549
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1494310551}
- component: {fileID: 1494310550}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &1494310550
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1494310549}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &1494310551
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1494310549}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}

7
Assets/Scenes/ARKit/ARKitGeoAnchors/ARKitGeoAnchors.unity.meta


fileFormatVersion: 2
guid: 338f0f26e48a9442c8562245d8bae9ab
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

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


using System;
using Unity.Collections;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
#if UNITY_IOS
using System.Runtime.InteropServices;
using UnityEngine.XR.ARKit;
// 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,
// 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);
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;
}
}
#endif
[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()
{
GUI.skin.label.fontSize = 50;
GUILayout.Space(100);
if (ARGeoAnchorConfigurationChooser.ARGeoTrackingConfigurationClass == IntPtr.Zero)
{
GUILayout.Label("ARGeoTrackingConfiguration is not supported on this device.");
return;
}
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;
}
}
void Update()
{
// Can't do anything interesting until location services are running.
if (Input.location.status != LocationServiceStatus.Running)
return;
if (GetComponent<ARSession>().subsystem is ARKitSessionSubsystem subsystem)
{
if (!(subsystem.configurationChooser is ARGeoAnchorConfigurationChooser))
{
// Replace the config chooser with our own
subsystem.configurationChooser = new ARGeoAnchorConfigurationChooser();
}
// 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;
// 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)
{
// Get last known location data
var locationData = Input.location.lastData;
// 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", EntryPoint = "ARSession_addGeoAnchor")]
static extern void AddGeoAnchor(IntPtr session, CLLocationCoordinate2D coordinate, double altitude);
#endif
}

11
Assets/Scenes/ARKit/ARKitGeoAnchors/EnableGeoAnchors.cs.meta


fileFormatVersion: 2
guid: 83ef5ba9cc0da4a19a969308a48e993d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

78
Assets/Scenes/ARKit/ARKitGeoAnchors/GeoAnchorsNativeInterop.m


#import <ARKit/ARKit.h>
// Gets the Objective-C metaclass for ARGeoTrackingConfiguration
Class ARGeoTrackingConfiguration_class() {
// ARGeoTrackingConfiguration requires iOS 14
if (@available(iOS 14, *)) {
if (ARGeoTrackingConfiguration.isSupported) {
return [ARGeoTrackingConfiguration class];
} else {
NSLog(@"ARGeoTrackingConfiguration is not supported on this device.");
}
}
return NULL;
}
// Adds an ARGeoAnchor to the ARSession
void ARSession_addGeoAnchor(void* self, CLLocationCoordinate2D coordinate, double altitude) {
if (@available(iOS 14, *)) {
// Cast the void* back to an ARSession
ARSession* session = (__bridge ARSession*)self;
// Create a new ARGeoAnchor
// See https://developer.apple.com/documentation/arkit/argeoanchor/3551719-initwithcoordinate?language=objc
ARGeoAnchor* geoAnchor = [[ARGeoAnchor alloc] initWithCoordinate:coordinate altitude:altitude];
// Add the new anchor to the session
[session addAnchor:geoAnchor];
NSLog(@"Added ARGeoAnchor at (%f, %f) at %f meters", coordinate.latitude, coordinate.longitude, altitude);
}
}
// Flips a transform from ARKit's right-handed coordinate system to Unity's left-handed coordinate system.
static inline simd_float4x4 FlipHandedness(simd_float4x4 transform) {
const simd_float4* c = transform.columns;
return simd_matrix(simd_make_float4( c[0].xy, -c[0].z, c[0].w),
simd_make_float4( c[1].xy, -c[1].z, c[1].w),
simd_make_float4(-c[2].xy, c[2].z, c[2].w),
simd_make_float4( c[3].xy, -c[3].z, c[3].w));
}
// Demonstrates "doing something" with the ARSession
void DoSomethingWithSession(void* sessionPtr) {
// ===============================
// Replace this with your own code
// ===============================
// In this example, just look for all ARGeoAnchors and print out their transforms.
if (@available(iOS 14, *)) {
ARSession* session = (__bridge ARSession*)sessionPtr;
for (ARAnchor* anchor in session.currentFrame.anchors) {
if ([anchor isKindOfClass:[ARGeoAnchor class]]) {
ARGeoAnchor* geoAnchor = (ARGeoAnchor*)anchor;
const simd_float4x4 transform = FlipHandedness(geoAnchor.transform);
const simd_float4* c = transform.columns;
NSLog(@"ARGeoAnchor %@ transform:\n"
"[%+f %+f %+f %+f]\n"
"[%+f %+f %+f %+f]\n"
"[%+f %+f %+f %+f]\n"
"[%+f %+f %+f %+f]\n",
[geoAnchor.identifier UUIDString],
c[0].x, c[1].x, c[2].x, c[3].x,
c[0].y, c[1].y, c[2].y, c[3].y,
c[0].z, c[1].z, c[2].z, c[3].z,
c[0].w, c[1].w, c[2].w, c[3].w);
}
}
}
}
bool ARFoundationSamples_IsiOS14OrLater() {
if (@available(iOS 14, *)) {
return true;
}
return false;
}

37
Assets/Scenes/ARKit/ARKitGeoAnchors/GeoAnchorsNativeInterop.m.meta


fileFormatVersion: 2
guid: f2965133628254dfea0af639813eae59
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

19
Assets/Scenes/ARKit/ARKitCoachingOverlay/CustomSessionDelegate.cs


#if UNITY_IOS
using UnityEngine.XR.ARKit;
namespace UnityEngine.XR.ARFoundation.Samples
{
public class CustomSessionDelegate : DefaultARKitSessionDelegate
{
protected override void OnCoachingOverlayViewWillActivate(ARKitSessionSubsystem sessionSubsystem)
{
Logger.Log(nameof(OnCoachingOverlayViewWillActivate));
}
protected override void OnCoachingOverlayViewDidDeactivate(ARKitSessionSubsystem sessionSubsystem)
{
Logger.Log(nameof(OnCoachingOverlayViewDidDeactivate));
}
}
}
#endif

11
Assets/Scenes/ARKit/ARKitCoachingOverlay/CustomSessionDelegate.cs.meta


fileFormatVersion: 2
guid: cad7396bd91de4031b8bd2c456f68941
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

/Assets/Scenes/ARWorldMap.unity → /Assets/Scenes/ARKit/ARWorldMap.unity

/Assets/Scenes/ARWorldMap.unity.meta → /Assets/Scenes/ARKit/ARWorldMap.unity.meta

/Assets/Scenes/ARCollaborationData.meta → /Assets/Scenes/ARKit/ARCollaborationData.meta

/Assets/Scenes/ARKitCoachingOverlay.meta → /Assets/Scenes/ARKit/ARKitCoachingOverlay.meta

/Assets/Scenes/ARKitCoachingOverlay → /Assets/Scenes/ARKit/ARKitCoachingOverlay

/Assets/Scenes/ARWorldMapSettings.lighting → /Assets/Scenes/ARKit/ARWorldMapSettings.lighting

/Assets/Scenes/ARWorldMapSettings.lighting.meta → /Assets/Scenes/ARKit/ARWorldMapSettings.lighting.meta

/Assets/Scenes/ThermalState.meta → /Assets/Scenes/ARKit/ThermalState.meta

/Assets/Scenes/ThermalState → /Assets/Scenes/ARKit/ThermalState

/Assets/Scenes/ARCollaborationData → /Assets/Scenes/ARKit/ARCollaborationData

正在加载...
取消
保存