浏览代码

Merge pull request #70 from unity/new-input-system

Sample Scene for New Input System
/4.1
GitHub Enterprise 4 年前
当前提交
96af161e
共有 14 个文件被更改,包括 1383 次插入3 次删除
  1. 232
      Assets/Scenes/ARFoundationMenu/Menu.unity
  2. 5
      Assets/Scripts/UX/ARSceneSelectUI.cs
  3. 9
      Assets/Scripts/UX/CheckAvailableFeatures.cs
  4. 1
      Packages/manifest.json
  5. 2
      ProjectSettings/ProjectSettings.asset
  6. 3
      README.md
  7. 8
      Assets/Scenes/InputSystem.meta
  8. 14
      Assets/Scenes/InputSystem/ARController.inputactions.meta
  9. 7
      Assets/Scenes/InputSystem/InputSystem.unity.meta
  10. 11
      Assets/Scenes/InputSystem/InputSystem_PlaceOnPlane.cs.meta
  11. 33
      Assets/Scenes/InputSystem/ARController.inputactions
  12. 1001
      Assets/Scenes/InputSystem/InputSystem.unity
  13. 60
      Assets/Scenes/InputSystem/InputSystem_PlaceOnPlane.cs

232
Assets/Scenes/ARFoundationMenu/Menu.unity


m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 765495906}
m_CullTransparentMesh: 0
--- !u!1 &769789621
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 769789622}
- component: {fileID: 769789624}
- component: {fileID: 769789623}
m_Layer: 5
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &769789622
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 769789621}
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: 1868840081}
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 &769789623
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 769789621}
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: Input System
--- !u!222 &769789624
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 769789621}
m_CullTransparentMesh: 0
--- !u!1 &774532497
GameObject:
m_ObjectHideFlags: 0

m_CheckSupport: {fileID: 912198813}
m_Depth: {fileID: 251164954}
m_ConfigChooser: {fileID: 2011106401}
m_InputSystem: {fileID: 1868840083}
--- !u!1 &786358435
GameObject:
m_ObjectHideFlags: 0

m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0.000015258789, y: 0.00009442632}
m_AnchoredPosition: {x: 0.000015258789, y: 0.0000618167}
m_SizeDelta: {x: 0, y: 1100}
m_Pivot: {x: 0, y: 1}
--- !u!1 &1416737520

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

- {fileID: 912198811}
- {fileID: 251164958}
- {fileID: 2011106399}
- {fileID: 1868840081}
m_Father: {fileID: 1413559114}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1847920808}
m_CullTransparentMesh: 0
--- !u!1 &1868840080
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1868840081}
- component: {fileID: 1868840085}
- component: {fileID: 1868840084}
- component: {fileID: 1868840083}
- component: {fileID: 1868840082}
m_Layer: 5
m_Name: InputSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1868840081
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1868840080}
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: 769789622}
m_Father: {fileID: 1569808631}
m_RootOrder: 22
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: -650}
m_SizeDelta: {x: 110, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1868840082
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1868840080}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 16733cd6749cf4d96be9df0329c6938a, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Tooltip: {fileID: 2094799242}
--- !u!114 &1868840083
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1868840080}
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: 1868840084}
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 774532498}
m_TargetAssemblyTypeName: UnityEngine.XR.ARFoundation.Samples.ARSceneSelectUI,
Assembly-CSharp
m_MethodName: InputSystemButtonPressed
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 &1868840084
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1868840080}
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 &1868840085
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1868840080}
m_CullTransparentMesh: 0
--- !u!1 &1895153661
GameObject:

5
Assets/Scripts/UX/ARSceneSelectUI.cs


{
LoadScene("DepthImages");
}
public void InputSystemButtonPressed()
{
LoadScene("InputSystem");
}
}
}

9
Assets/Scripts/UX/CheckAvailableFeatures.cs


set => m_ConfigChooser = value;
}
[SerializeField]
Button m_InputSystem;
public Button inputSystem
{
get => m_InputSystem;
set => m_InputSystem = value;
}
// Start is called before the first frame update
void Start()
{

m_SampleUX.interactable = true;
m_CheckSupport.interactable = true;
m_ConfigChooser.interactable = true;
m_InputSystem.interactable = true;
}
if(faceDescriptors.Count > 0)

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",

2
ProjectSettings/ProjectSettings.asset


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

3
README.md


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.
# Community and Feedback
The intention of this reposititory is to provide a means for getting started with the features in ARFoundation. The samples are intentionally simplistic with a focus on teaching basic scene setup and APIs. If you you have a question, find a bug, or would like to request a new feature concerning any of the ARFoundation packages or these samples please [submit a GitHub issue](https://github.com/Unity-Technologies/arfoundation-samples/issues). New issues are reviewed regularly.

8
Assets/Scenes/InputSystem.meta


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

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:

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


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

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:

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

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

60
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)
{
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;
}
}
正在加载...
取消
保存