GitHub Enterprise
4 年前
当前提交
96af161e
共有 14 个文件被更改,包括 1383 次插入 和 3 次删除
-
232Assets/Scenes/ARFoundationMenu/Menu.unity
-
5Assets/Scripts/UX/ARSceneSelectUI.cs
-
9Assets/Scripts/UX/CheckAvailableFeatures.cs
-
1Packages/manifest.json
-
2ProjectSettings/ProjectSettings.asset
-
3README.md
-
8Assets/Scenes/InputSystem.meta
-
14Assets/Scenes/InputSystem/ARController.inputactions.meta
-
7Assets/Scenes/InputSystem/InputSystem.unity.meta
-
11Assets/Scenes/InputSystem/InputSystem_PlaceOnPlane.cs.meta
-
33Assets/Scenes/InputSystem/ARController.inputactions
-
1001Assets/Scenes/InputSystem/InputSystem.unity
-
60Assets/Scenes/InputSystem/InputSystem_PlaceOnPlane.cs
|
|||
fileFormatVersion: 2 |
|||
guid: 52c7024febbc64d74b15582666a36764 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 91fef793c01e643e0a22041c59decd81 |
|||
ScriptedImporter: |
|||
internalIDToNameTable: [] |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3} |
|||
generateWrapperCode: 0 |
|||
wrapperCodePath: |
|||
wrapperClassName: |
|||
wrapperCodeNamespace: |
|
|||
fileFormatVersion: 2 |
|||
guid: 3956525d2e8364c3bad0d962f5821708 |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 47d91ec5b7feb4c8f8dd9a3f8c7fdc09 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
{ |
|||
"name": "ARController", |
|||
"maps": [ |
|||
{ |
|||
"name": "ARTouchScreen", |
|||
"id": "9c30ce86-19ea-4a18-844a-5099b6fd04ca", |
|||
"actions": [ |
|||
{ |
|||
"name": "AddObject", |
|||
"type": "Value", |
|||
"id": "887b4a07-8f22-4b39-b134-9af1ffa26013", |
|||
"expectedControlType": "Vector2", |
|||
"processors": "", |
|||
"interactions": "" |
|||
} |
|||
], |
|||
"bindings": [ |
|||
{ |
|||
"name": "", |
|||
"id": "97ce382a-a7cf-43aa-90f7-3f4554ec2f7a", |
|||
"path": "<Touchscreen>/primaryTouch/position", |
|||
"interactions": "", |
|||
"processors": "", |
|||
"groups": "", |
|||
"action": "AddObject", |
|||
"isComposite": false, |
|||
"isPartOfComposite": false |
|||
} |
|||
] |
|||
} |
|||
], |
|||
"controlSchemes": [] |
|||
} |
1001
Assets/Scenes/InputSystem/InputSystem.unity
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.XR.ARFoundation; |
|||
using UnityEngine.XR.ARSubsystems; |
|||
using UnityEngine.InputSystem; |
|||
|
|||
namespace UnityEngine.XR.ARFoundation.Samples |
|||
{ |
|||
public class InputSystem_PlaceOnPlane : MonoBehaviour |
|||
{ |
|||
|
|||
[SerializeField] |
|||
[Tooltip("Instantiates this prefab on a plane at the touch location.")] |
|||
GameObject m_PlacedPrefab; |
|||
|
|||
/// <summary>
|
|||
/// The prefab to instantiate on touch.
|
|||
/// </summary>
|
|||
public GameObject placedPrefab |
|||
{ |
|||
get { return m_PlacedPrefab; } |
|||
set { m_PlacedPrefab = value; } |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// The object instantiated as a result of a successful raycast intersection with a plane.
|
|||
/// </summary>
|
|||
public GameObject spawnedObject { get; private set; } |
|||
|
|||
void Awake() |
|||
{ |
|||
m_RaycastManager = GetComponent<ARRaycastManager>(); |
|||
} |
|||
|
|||
public void AddObject(InputAction.CallbackContext context) |
|||
{ |
|||
var touchPosition = context.ReadValue<Vector2>(); |
|||
if (m_RaycastManager.Raycast(touchPosition, s_Hits, TrackableType.PlaneWithinPolygon)) |
|||
{ |
|||
// Raycast hits are sorted by distance, so the first one
|
|||
// will be the closest hit.
|
|||
var hitPose = s_Hits[0].pose; |
|||
|
|||
if (spawnedObject == null) |
|||
{ |
|||
spawnedObject = Instantiate(m_PlacedPrefab, hitPose.position, hitPose.rotation); |
|||
} |
|||
else |
|||
{ |
|||
spawnedObject.transform.position = hitPose.position; |
|||
} |
|||
} |
|||
} |
|||
|
|||
static List<ARRaycastHit> s_Hits = new List<ARRaycastHit>(); |
|||
|
|||
ARRaycastManager m_RaycastManager; |
|||
} |
|||
|
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue