浏览代码

init input sample scene

/4.1
Alexandra Serralta 4 年前
当前提交
49e76a1a
共有 10 个文件被更改,包括 1147 次插入2 次删除
  1. 1
      Packages/manifest.json
  2. 6
      ProjectSettings/ProjectSettings.asset
  3. 8
      Assets/Scenes/InputSystem.meta
  4. 33
      Assets/Scenes/InputSystem/ARController.inputactions
  5. 14
      Assets/Scenes/InputSystem/ARController.inputactions.meta
  6. 1001
      Assets/Scenes/InputSystem/InputSystem.unity
  7. 7
      Assets/Scenes/InputSystem/InputSystem.unity.meta
  8. 68
      Assets/Scenes/InputSystem/InputSystem_PlaceOnPlane.cs
  9. 11
      Assets/Scenes/InputSystem/InputSystem_PlaceOnPlane.cs.meta

1
Packages/manifest.json


"com.unity.ide.rider": "1.2.1",
"com.unity.ide.visualstudio": "2.0.2",
"com.unity.ide.vscode": "1.2.1",
"com.unity.inputsystem": "1.0.0",
"com.unity.purchasing": "2.0.6",
"com.unity.test-framework": "1.1.16",
"com.unity.textmeshpro": "3.0.1",

6
ProjectSettings/ProjectSettings.asset


16:9: 1
Others: 1
bundleVersion: 0.1
preloadedAssets: []
preloadedAssets:
- {fileID: 0}
- {fileID: -6122771651556369562, guid: e2f869774b12e400996eb546603602e3, type: 2}
metroInputSource: 0
wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1

projectName: Template_3D
organizationId:
cloudEnabled: 0
enableNativePlatformBackendsForNewInputSystem: 0
enableNativePlatformBackendsForNewInputSystem: 1
disableOldInputManagerSupport: 0
legacyClampBlendShapeWeights: 1
virtualTexturingSupportEnabled: 0

8
Assets/Scenes/InputSystem.meta


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

33
Assets/Scenes/InputSystem/ARController.inputactions


{
"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",
"interactions": "",
"processors": "",
"groups": "",
"action": "AddObject",
"isComposite": false,
"isPartOfComposite": false
}
]
}
],
"controlSchemes": []
}

14
Assets/Scenes/InputSystem/ARController.inputactions.meta


fileFormatVersion: 2
guid: 91fef793c01e643e0a22041c59decd81
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
generateWrapperCode: 0
wrapperCodePath:
wrapperClassName:
wrapperCodeNamespace:

1001
Assets/Scenes/InputSystem/InputSystem.unity
文件差异内容过多而无法显示
查看文件

7
Assets/Scenes/InputSystem/InputSystem.unity.meta


fileFormatVersion: 2
guid: 3956525d2e8364c3bad0d962f5821708
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

68
Assets/Scenes/InputSystem/InputSystem_PlaceOnPlane.cs


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)
{
Debug.Log("Spawn!");
var touchPosition = context.ReadValue<Vector2>();
Debug.Log(touchPosition);
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;
}
}
}
// Update is called once per frame
void Update()
{
}
static List<ARRaycastHit> s_Hits = new List<ARRaycastHit>();
ARRaycastManager m_RaycastManager;
}
}

11
Assets/Scenes/InputSystem/InputSystem_PlaceOnPlane.cs.meta


fileFormatVersion: 2
guid: 47d91ec5b7feb4c8f8dd9a3f8c7fdc09
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存