浏览代码

Merge remote-tracking branch 'origin/latest-preview' into latest-preview

/4.1
Tim Mowrer 4 年前
当前提交
16086156
共有 5 个文件被更改,包括 158 次插入33 次删除
  1. 121
      Assets/Scenes/Anchors.unity
  2. 15
      Assets/Scenes/InputSystem/InputSystem.unity
  3. 3
      Assets/Scenes/LightEstimation/FacingDirectionManager.cs
  4. 46
      Assets/Scripts/AnchorCreator.cs
  5. 6
      README.md

121
Assets/Scenes/Anchors.unity


m_Children:
- {fileID: 551691157}
m_Father: {fileID: 948874508}
m_RootOrder: 1
m_RootOrder: 2
m_AnchoredPosition: {x: -225, y: 64}
m_SizeDelta: {x: 450, y: 256}
m_Pivot: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 64}
m_SizeDelta: {x: 300, y: 150}
m_Pivot: {x: 0.5, y: 0}
--- !u!114 &358479874
MonoBehaviour:
m_ObjectHideFlags: 0

m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 1968325546}
- {fileID: 3475649455839500782}
- {fileID: 358479873}
m_Father: {fileID: 0}

- component: {fileID: 1335839535}
- component: {fileID: 1335839534}
- component: {fileID: 1335839536}
- component: {fileID: 1335839537}
- component: {fileID: 1335839539}
- component: {fileID: 1335839540}
- component: {fileID: 1335839538}

m_EditorClassIdentifier:
m_PointCloudPrefab: {fileID: 1854016325464908, guid: 0d4f49e744bffd14eb527ba76c9bba12,
type: 3}
--- !u!114 &1335839537
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1335839533}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e1760703bbd54c04488a8d10600262ab, type: 3}
m_Name:
m_EditorClassIdentifier:
m_PlanePrefab: {fileID: 1568414836858200, guid: f0e0be81472ff1243aa2afa27e5d0e61,
type: 3}
m_DetectionMode: -1
--- !u!114 &1335839538
MonoBehaviour:
m_ObjectHideFlags: 0

m_EditorClassIdentifier:
m_AnchorPrefab: {fileID: 1362899771367802, guid: 8fe3e998d2f7f4eb8ac84726705ca1fd,
type: 3}
--- !u!1 &1968325545
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1968325546}
- component: {fileID: 1968325549}
- component: {fileID: 1968325548}
- component: {fileID: 1968325547}
m_Layer: 5
m_Name: Log
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1968325546
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1968325545}
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: 948874508}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 25, y: -75}
m_SizeDelta: {x: 640, y: 800}
m_Pivot: {x: 0, y: 1}
--- !u!114 &1968325547
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1968325545}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6b9ec441ecd1d4c21b5736659749bcf2, type: 3}
m_Name:
m_EditorClassIdentifier:
m_LogText: {fileID: 0}
m_VisibleMessageCount: 40
--- !u!114 &1968325548
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1968325545}
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: New Text
--- !u!222 &1968325549
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1968325545}
m_CullTransparentMesh: 0
--- !u!1001 &3475649455839500781
PrefabInstance:
m_ObjectHideFlags: 0

- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}
propertyPath: m_RootOrder
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2304810881573073946, guid: 4ee22c1f54b174122b6a766fe09e0de8,
type: 3}

15
Assets/Scenes/InputSystem/InputSystem.unity


- component: {fileID: 762671672}
- component: {fileID: 762671671}
- component: {fileID: 762671670}
- component: {fileID: 762671669}
- component: {fileID: 762671676}
m_Layer: 0
m_Name: AR Session Origin

m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &762671669
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 762671668}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7d5359d5f13250e4485741ed685a32be, type: 3}
m_Name:
m_EditorClassIdentifier:
m_PlacedPrefab: {fileID: 1934569588295450, guid: b34b6c8f1206a6844b983e23b9da0441,
type: 3}
--- !u!114 &762671670
MonoBehaviour:
m_ObjectHideFlags: 0

3
Assets/Scenes/LightEstimation/FacingDirectionManager.cs


/// </summary>
[RequireComponent(typeof(ARSessionOrigin))]
[RequireComponent(typeof(ARFaceManager))]
[RequireComponent(typeof(ARCameraManager))]
[SerializeField]
[SerializeField]
GameObject m_WorldSpaceObject;
public GameObject worldSpaceObject

46
Assets/Scripts/AnchorCreator.cs


{
public void RemoveAllAnchors()
{
Logger.Log($"Removing all anchors ({m_Anchors.Count})");
foreach (var anchor in m_Anchors)
{
m_AnchorManager.RemoveAnchor(anchor);

{
m_RaycastManager = GetComponent<ARRaycastManager>();
m_AnchorManager = GetComponent<ARAnchorManager>();
m_Anchors = new List<ARAnchor>();
}
ARAnchor CreateAnchor(in ARRaycastHit hit)
{
// If we hit a plane, try to "attach" the anchor to the plane
if (hit.trackable is ARPlane plane)
{
var planeManager = GetComponent<ARPlaneManager>();
if (planeManager)
{
Logger.Log("Creating anchor attachment.");
return m_AnchorManager.AttachAnchor(plane, hit.pose);
}
}
// Otherwise, just create a regular anchor at the hit pose
Logger.Log("Creating regular anchor.");
return m_AnchorManager.AddAnchor(hit.pose);
}
void Update()

if (touch.phase != TouchPhase.Began)
return;
if (m_RaycastManager.Raycast(touch.position, s_Hits, TrackableType.FeaturePoint))
// Raycast against planes and feature points
const TrackableType trackableTypes =
TrackableType.FeaturePoint |
TrackableType.PlaneWithinPolygon;
// Perform the raycast
if (m_RaycastManager.Raycast(touch.position, s_Hits, trackableTypes))
// Raycast hits are sorted by distance, so the first one
// will be the closest hit.
var hitPose = s_Hits[0].pose;
var anchor = m_AnchorManager.AddAnchor(hitPose);
if (anchor == null)
// Raycast hits are sorted by distance, so the first one will be the closest hit.
var hit = s_Hits[0];
// Create a new anchor
var anchor = CreateAnchor(hit);
if (anchor)
Logger.Log("Error creating anchor");
// Remember the anchor so we can remove it later.
m_Anchors.Add(anchor);
m_Anchors.Add(anchor);
Logger.Log("Error creating anchor");
}
}
}

List<ARAnchor> m_Anchors;
List<ARAnchor> m_Anchors = new List<ARAnchor>();
ARRaycastManager m_RaycastManager;

6
README.md


This sample shows how to create anchors as the result of a raycast hit. The "Clear Anchors" button removes all created anchors. See the [`AnchorCreator.cs`](https://github.com/Unity-Technologies/arfoundation-samples/blob/master/Assets/Scripts/AnchorCreator.cs) script.
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.
## Scale
This sample shows how to adjust the apparent scale of content in an AR scene. It does this by moving, rotating, and scaling the `ARSessionOrigin` instead of the content. Complex scenes often can't be moved after creation (e.g., terrain), and scale can negatively affect other systems such as physics, particle effects, and AI navigation. The `ARSessionOrigin`'s scale feature is useful if you want to make your content "appear" at a position on a detected plane and to scale, for example, a building sized object to a table-top miniature.

This sample scene demonstrates the functionality of the `XR Interaction Toolkit` package. In the scene, you are able to place a cube on a plane which you can translate, rotate and scale with gestures. See the [`XR Interaction Toolkit Documentation`](https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@0.9/manual/index.html) for more details.
## Input System
This sample demonstrates a version of the SimpleAR scene using Unity's new Input System. See the [`Input System Documentation`](https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/index.html) for more details.
This sample demonstrates a version of the SimpleAR scene using Unity's new Input System. See [`ARController.inputactions`](https://github.com/Unity-Technologies/arfoundation-samples/blob/latest-preview/Assets/Scenes/InputSystem/ARController.inputactions) for an example of an action map. For a demonstration on how these action map bindings are used, see the [`InputSystem_PlaceOnPlane.cs`](https://github.com/Unity-Technologies/arfoundation-samples/blob/latest-preview/Assets/Scenes/InputSystem/InputSystem_PlaceOnPlane.cs) script. For more details, see the [`Input System Documentation`](https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/index.html).
# Community and Feedback

正在加载...
取消
保存