diff --git a/Assets/HoloToolkit-Examples/Input/Prefabs/LinearControllerPointerMultiColors.prefab b/Assets/HoloToolkit-Examples/Input/Prefabs/LinearControllerPointerMultiColors.prefab new file mode 100644 index 00000000000..1a2ab78ed41 --- /dev/null +++ b/Assets/HoloToolkit-Examples/Input/Prefabs/LinearControllerPointerMultiColors.prefab @@ -0,0 +1,327 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1406990951443512} + m_IsPrefabParent: 1 +--- !u!1 &1406990951443512 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4078510770057468} + - component: {fileID: 114475473728920830} + - component: {fileID: 114253695620597976} + - component: {fileID: 114337282513792584} + - component: {fileID: 114056157604016048} + m_Layer: 0 + m_Name: LinearControllerPointerMultiColors + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4078510770057468 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1406990951443512} + 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: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &114056157604016048 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1406990951443512} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f9a4d6e2d0d55194788e9a2df9c0261f, type: 3} + m_Name: + m_EditorClassIdentifier: + source: {fileID: 114337282513792584} + LineColor: + serializedVersion: 2 + key0: {r: 1, g: 1, b: 1, a: 1} + key1: {r: 1, g: 1, b: 1, a: 1} + key2: {r: 0, g: 0, b: 0, a: 0} + key3: {r: 0, g: 0, b: 0, a: 0} + key4: {r: 0, g: 0, b: 0, a: 0} + key5: {r: 0, g: 0, b: 0, a: 0} + key6: {r: 0, g: 0, b: 0, a: 0} + key7: {r: 0, g: 0, b: 0, a: 0} + ctime0: 0 + ctime1: 65535 + ctime2: 0 + ctime3: 0 + ctime4: 0 + ctime5: 0 + ctime6: 0 + ctime7: 0 + atime0: 0 + atime1: 65535 + atime2: 0 + atime3: 0 + atime4: 0 + atime5: 0 + atime6: 0 + atime7: 0 + m_Mode: 0 + m_NumColorKeys: 2 + m_NumAlphaKeys: 2 + LineWidth: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 0.05 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + - serializedVersion: 2 + time: 1 + value: 0.05 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + WidthMultiplier: 0.1 + ColorOffset: 0 + WidthOffset: 0 + RotationOffset: 0 + StepMode: 0 + NumLineSteps: 10 + InterpolationMode: 1 + StepLength: 0.05 + MaxLineSteps: 2048 + StepLengthCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 1 + inSlope: 0 + outSlope: -0.5 + tangentMode: 0 + - serializedVersion: 2 + time: 1 + value: 0.5 + inSlope: -0.5 + outSlope: 0 + tangentMode: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + LineMaterial: {fileID: 2100000, guid: d9f5efc2f1dfc6846a9ebeac2f029eff, type: 2} + RoundedEdges: 1 + RoundedCaps: 1 + lineRenderer: {fileID: 0} +--- !u!114 &114253695620597976 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1406990951443512} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: df317dc594e50444da58008aa4ee1475, type: 3} + m_Name: + m_EditorClassIdentifier: + element: 6 + handedness: 0 + SetChildrenInactiveWhenDetached: 1 + PositionOffset: {x: 0, y: 0, z: 0} + RotationOffset: {x: 0, y: 0, z: 0} + ScaleOffset: {x: 1, y: 1, z: 1} + SetScaleOnAttach: 0 + CurrentPointerOrientation: 0 + extentOverride: 2 + RaycastOrigin: {fileID: 0} + LineColorSelected: + serializedVersion: 2 + key0: {r: 0, g: 0.57254905, b: 0.57254905, a: 0} + key1: {r: 0, g: 0.35686275, b: 0.42745098, a: 1} + key2: {r: 0, g: 0.1882353, b: 0.3019608, a: 1} + key3: {r: 0, g: 0, b: 0, a: 0} + key4: {r: 0, g: 0, b: 0, a: 0} + key5: {r: 0, g: 0, b: 0, a: 0} + key6: {r: 0, g: 0, b: 0, a: 0} + key7: {r: 0, g: 0, b: 0, a: 0} + ctime0: 0 + ctime1: 33751 + ctime2: 65535 + ctime3: 0 + ctime4: 0 + ctime5: 0 + ctime6: 0 + ctime7: 0 + atime0: 0 + atime1: 4981 + atime2: 60554 + atime3: 65535 + atime4: 0 + atime5: 0 + atime6: 0 + atime7: 0 + m_Mode: 0 + m_NumColorKeys: 3 + m_NumAlphaKeys: 4 + LineColorValid: + serializedVersion: 2 + key0: {r: 0.06666667, g: 0.57254905, b: 0, a: 0} + key1: {r: 0, g: 0.42745098, b: 0.003921569, a: 1} + key2: {r: 0.011764706, g: 0.3019608, b: 0, a: 1} + key3: {r: 0, g: 0, b: 0, a: 0} + key4: {r: 0, g: 0, b: 0, a: 0} + key5: {r: 0, g: 0, b: 0, a: 0} + key6: {r: 0, g: 0, b: 0, a: 0} + key7: {r: 0, g: 0, b: 0, a: 0} + ctime0: 0 + ctime1: 33751 + ctime2: 65535 + ctime3: 0 + ctime4: 0 + ctime5: 0 + ctime6: 0 + ctime7: 0 + atime0: 0 + atime1: 4981 + atime2: 60554 + atime3: 65535 + atime4: 0 + atime5: 0 + atime6: 0 + atime7: 0 + m_Mode: 0 + m_NumColorKeys: 3 + m_NumAlphaKeys: 4 + LineColorNoTarget: + serializedVersion: 2 + key0: {r: 0.52156866, g: 0.52156866, b: 0.52156866, a: 0} + key1: {r: 0.32156864, g: 0.32156864, b: 0.32156864, a: 1} + key2: {r: 0.15294118, g: 0.15294118, b: 0.15294118, a: 1} + key3: {r: 0, g: 0, b: 0, a: 0} + key4: {r: 0, g: 0, b: 0, a: 0} + key5: {r: 0, g: 0, b: 0, a: 0} + key6: {r: 0, g: 0, b: 0, a: 0} + key7: {r: 0, g: 0, b: 0, a: 0} + ctime0: 0 + ctime1: 33751 + ctime2: 65535 + ctime3: 0 + ctime4: 0 + ctime5: 0 + ctime6: 0 + ctime7: 0 + atime0: 0 + atime1: 4981 + atime2: 60554 + atime3: 65535 + atime4: 0 + atime5: 0 + atime6: 0 + atime7: 0 + m_Mode: 0 + m_NumColorKeys: 3 + m_NumAlphaKeys: 4 + LineCastResolution: 25 + LineBase: {fileID: 0} + LineRenderers: [] +--- !u!114 &114337282513792584 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1406990951443512} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bec4b46028f8fb94c9b03b88fca37bd6, type: 3} + m_Name: + m_EditorClassIdentifier: + LineStartClamp: 0 + LineEndClamp: 1 + RotationType: 1 + FlipUpVector: 0 + OriginOffset: {x: 0, y: 0, z: 0} + ManualUpVectorBlend: 0 + ManualUpVectors: + - {x: 0, y: 1, z: 0} + - {x: 0, y: 1, z: 0} + - {x: 0, y: 1, z: 0} + VelocitySearchRange: 0.02 + VelocityBlend: 0.5 + DistortionType: 0 + DistortionStrength: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + - serializedVersion: 2 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + UniformDistortionStrength: 1 + distorters: [] + loops: 0 + Start: {x: 0, y: 0, z: 0} + End: {x: 1, y: 1, z: 1} +--- !u!114 &114475473728920830 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1406990951443512} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3be3fb966fbcc0f44add9a39d15cd3d0, type: 3} + m_Name: + m_EditorClassIdentifier: + distortOrder: 0 + distortStrength: 1 + LocalCenterOfGravity: {x: 0, y: 0, z: 0} + AxisStrength: {x: 1, y: 1, z: 1} + Radius: 0.5 + GravityStrength: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + - serializedVersion: 2 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 diff --git a/Assets/HoloToolkit-Examples/Input/Prefabs/LinearControllerPointerMultiColors.prefab.meta b/Assets/HoloToolkit-Examples/Input/Prefabs/LinearControllerPointerMultiColors.prefab.meta new file mode 100644 index 00000000000..3bb8c94726a --- /dev/null +++ b/Assets/HoloToolkit-Examples/Input/Prefabs/LinearControllerPointerMultiColors.prefab.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e9556ced730993f4d986bf3a04c1a459 +timeCreated: 1527028987 +licenseType: Pro +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HoloToolkit-Examples/Input/Scenes/MotionControllerTest.unity b/Assets/HoloToolkit-Examples/Input/Scenes/MotionControllerTest.unity index 263cefe8f87..4131f4f9346 100644 --- a/Assets/HoloToolkit-Examples/Input/Scenes/MotionControllerTest.unity +++ b/Assets/HoloToolkit-Examples/Input/Scenes/MotionControllerTest.unity @@ -1533,9 +1533,9 @@ MeshCollider: m_Material: {fileID: 0} m_IsTrigger: 0 m_Enabled: 1 - serializedVersion: 2 + serializedVersion: 3 m_Convex: 0 - m_InflateMesh: 0 + m_CookingOptions: 14 m_SkinWidth: 0.01 m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} --- !u!33 &370377251 @@ -2766,35 +2766,6 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 ---- !u!1 &648067039 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 5 - m_Component: - - component: {fileID: 648067040} - m_Layer: 0 - m_Name: Managers - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &648067040 -Transform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 648067039} - 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: 844015981} - m_Father: {fileID: 0} - m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &663988535 GameObject: m_ObjectHideFlags: 0 @@ -3483,11 +3454,6 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 ---- !u!4 &844015981 stripped -Transform: - m_PrefabParentObject: {fileID: 4000011656901714, guid: 3eddd1c29199313478dd3f912bfab2ab, - type: 2} - m_PrefabInternal: {fileID: 1873443075} --- !u!1 &852192631 GameObject: m_ObjectHideFlags: 0 @@ -7632,7 +7598,7 @@ Prefab: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: - m_TransformParent: {fileID: 648067040} + m_TransformParent: {fileID: 0} m_Modifications: - target: {fileID: 4000011656901714, guid: 3eddd1c29199313478dd3f912bfab2ab, type: 2} propertyPath: m_LocalPosition.x @@ -7648,15 +7614,15 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 4000011656901714, guid: 3eddd1c29199313478dd3f912bfab2ab, type: 2} propertyPath: m_LocalRotation.x - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 4000011656901714, guid: 3eddd1c29199313478dd3f912bfab2ab, type: 2} propertyPath: m_LocalRotation.y - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 4000011656901714, guid: 3eddd1c29199313478dd3f912bfab2ab, type: 2} propertyPath: m_LocalRotation.z - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 4000011656901714, guid: 3eddd1c29199313478dd3f912bfab2ab, type: 2} propertyPath: m_LocalRotation.w @@ -7664,7 +7630,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 4000011656901714, guid: 3eddd1c29199313478dd3f912bfab2ab, type: 2} propertyPath: m_RootOrder - value: 0 + value: 2 objectReference: {fileID: 0} - target: {fileID: 114742747811649402, guid: 3eddd1c29199313478dd3f912bfab2ab, type: 2} diff --git a/Assets/HoloToolkit/Common/Scripts/Enums.meta b/Assets/HoloToolkit/Common/Scripts/Enums.meta new file mode 100644 index 00000000000..ce847cf091f --- /dev/null +++ b/Assets/HoloToolkit/Common/Scripts/Enums.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d5c1479ce975e4041b97c2311373b648 +folderAsset: yes +timeCreated: 1525974744 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HoloToolkit/Common/Scripts/Enums/Handedness.cs b/Assets/HoloToolkit/Common/Scripts/Enums/Handedness.cs new file mode 100644 index 00000000000..86e3e62778c --- /dev/null +++ b/Assets/HoloToolkit/Common/Scripts/Enums/Handedness.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; + +namespace HoloToolkit.Unity +{ + [Flags] + public enum Handedness + { + Unknown, + Left, + Right + } +} diff --git a/Assets/HoloToolkit/Common/Scripts/Enums/Handedness.cs.meta b/Assets/HoloToolkit/Common/Scripts/Enums/Handedness.cs.meta new file mode 100644 index 00000000000..18474b88861 --- /dev/null +++ b/Assets/HoloToolkit/Common/Scripts/Enums/Handedness.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 09a918e45dbacfb43abb0b812a5e524d +timeCreated: 1525974761 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HoloToolkit/Input/Materials/LineMaterial.mat b/Assets/HoloToolkit/Input/Materials/LineMaterial.mat new file mode 100644 index 00000000000..06092716ac6 --- /dev/null +++ b/Assets/HoloToolkit/Input/Materials/LineMaterial.mat @@ -0,0 +1,78 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: LineMaterial + m_Shader: {fileID: 203, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _InvFade: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _TintColor: {r: 1, g: 1, b: 1, a: 1} diff --git a/Assets/HoloToolkit/Input/Materials/LineMaterial.mat.meta b/Assets/HoloToolkit/Input/Materials/LineMaterial.mat.meta new file mode 100644 index 00000000000..a48577ab93e --- /dev/null +++ b/Assets/HoloToolkit/Input/Materials/LineMaterial.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d9f5efc2f1dfc6846a9ebeac2f029eff +timeCreated: 1526058862 +licenseType: Pro +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HoloToolkit/Input/Prefabs/InputManager.prefab b/Assets/HoloToolkit/Input/Prefabs/InputManager.prefab index 4ce3d574537..48463b88f40 100644 --- a/Assets/HoloToolkit/Input/Prefabs/InputManager.prefab +++ b/Assets/HoloToolkit/Input/Prefabs/InputManager.prefab @@ -288,6 +288,7 @@ Camera: m_TargetEye: 3 m_HDR: 0 m_AllowMSAA: 0 + m_AllowDynamicResolution: 0 m_ForceIntoRT: 0 m_OcclusionCulling: 0 m_StereoConvergence: 10 @@ -514,7 +515,10 @@ MonoBehaviour: m_EditorClassIdentifier: ControllerPointerStabilizer: {fileID: 114345042324023316} Cursor: {fileID: 0} - SearchForCursorIfUnset: 1 + searchForCursorIfUnset: 1 + autoselectBestAvailable: 0 + linePointerPrefab: {fileID: 1071219928950220, guid: 7dd8661d4bacf2546a0237daef280291, + type: 2} --- !u!114 &114749671304188880 MonoBehaviour: m_ObjectHideFlags: 1 diff --git a/Assets/HoloToolkit/Input/Prefabs/LinearControllerPointer.prefab b/Assets/HoloToolkit/Input/Prefabs/LinearControllerPointer.prefab new file mode 100644 index 00000000000..c04ac31174b --- /dev/null +++ b/Assets/HoloToolkit/Input/Prefabs/LinearControllerPointer.prefab @@ -0,0 +1,327 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1071219928950220} + m_IsPrefabParent: 1 +--- !u!1 &1071219928950220 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4249092239764520} + - component: {fileID: 114864358960263782} + - component: {fileID: 114072886165955432} + - component: {fileID: 114599709742384530} + - component: {fileID: 114508479835528396} + m_Layer: 0 + m_Name: LinearControllerPointer + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4249092239764520 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1071219928950220} + 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: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &114072886165955432 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1071219928950220} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: df317dc594e50444da58008aa4ee1475, type: 3} + m_Name: + m_EditorClassIdentifier: + element: 6 + handedness: 0 + SetChildrenInactiveWhenDetached: 1 + PositionOffset: {x: 0, y: 0, z: 0} + RotationOffset: {x: 0, y: 0, z: 0} + ScaleOffset: {x: 1, y: 1, z: 1} + SetScaleOnAttach: 0 + CurrentPointerOrientation: 0 + extentOverride: 2 + RaycastOrigin: {fileID: 0} + LineColorSelected: + serializedVersion: 2 + key0: {r: 0.52156866, g: 0.52156866, b: 0.52156866, a: 0} + key1: {r: 0.32156864, g: 0.32156864, b: 0.32156864, a: 1} + key2: {r: 0.15294118, g: 0.15294118, b: 0.15294118, a: 1} + key3: {r: 0, g: 0, b: 0, a: 0} + key4: {r: 0, g: 0, b: 0, a: 0} + key5: {r: 0, g: 0, b: 0, a: 0} + key6: {r: 0, g: 0, b: 0, a: 0} + key7: {r: 0, g: 0, b: 0, a: 0} + ctime0: 0 + ctime1: 33751 + ctime2: 65535 + ctime3: 0 + ctime4: 0 + ctime5: 0 + ctime6: 0 + ctime7: 0 + atime0: 0 + atime1: 4981 + atime2: 60554 + atime3: 65535 + atime4: 0 + atime5: 0 + atime6: 0 + atime7: 0 + m_Mode: 0 + m_NumColorKeys: 3 + m_NumAlphaKeys: 4 + LineColorValid: + serializedVersion: 2 + key0: {r: 0.52156866, g: 0.52156866, b: 0.52156866, a: 0} + key1: {r: 0.32156864, g: 0.32156864, b: 0.32156864, a: 1} + key2: {r: 0.15294118, g: 0.15294118, b: 0.15294118, a: 1} + key3: {r: 0, g: 0, b: 0, a: 0} + key4: {r: 0, g: 0, b: 0, a: 0} + key5: {r: 0, g: 0, b: 0, a: 0} + key6: {r: 0, g: 0, b: 0, a: 0} + key7: {r: 0, g: 0, b: 0, a: 0} + ctime0: 0 + ctime1: 33751 + ctime2: 65535 + ctime3: 0 + ctime4: 0 + ctime5: 0 + ctime6: 0 + ctime7: 0 + atime0: 0 + atime1: 4981 + atime2: 60554 + atime3: 65535 + atime4: 0 + atime5: 0 + atime6: 0 + atime7: 0 + m_Mode: 0 + m_NumColorKeys: 3 + m_NumAlphaKeys: 4 + LineColorNoTarget: + serializedVersion: 2 + key0: {r: 0.52156866, g: 0.52156866, b: 0.52156866, a: 0} + key1: {r: 0.32156864, g: 0.32156864, b: 0.32156864, a: 1} + key2: {r: 0.15294118, g: 0.15294118, b: 0.15294118, a: 1} + key3: {r: 0, g: 0, b: 0, a: 0} + key4: {r: 0, g: 0, b: 0, a: 0} + key5: {r: 0, g: 0, b: 0, a: 0} + key6: {r: 0, g: 0, b: 0, a: 0} + key7: {r: 0, g: 0, b: 0, a: 0} + ctime0: 0 + ctime1: 33751 + ctime2: 65535 + ctime3: 0 + ctime4: 0 + ctime5: 0 + ctime6: 0 + ctime7: 0 + atime0: 0 + atime1: 4981 + atime2: 60554 + atime3: 65535 + atime4: 0 + atime5: 0 + atime6: 0 + atime7: 0 + m_Mode: 0 + m_NumColorKeys: 3 + m_NumAlphaKeys: 4 + LineCastResolution: 25 + LineBase: {fileID: 0} + LineRenderers: [] +--- !u!114 &114508479835528396 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1071219928950220} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f9a4d6e2d0d55194788e9a2df9c0261f, type: 3} + m_Name: + m_EditorClassIdentifier: + source: {fileID: 114599709742384530} + LineColor: + serializedVersion: 2 + key0: {r: 1, g: 1, b: 1, a: 1} + key1: {r: 1, g: 1, b: 1, a: 1} + key2: {r: 0, g: 0, b: 0, a: 0} + key3: {r: 0, g: 0, b: 0, a: 0} + key4: {r: 0, g: 0, b: 0, a: 0} + key5: {r: 0, g: 0, b: 0, a: 0} + key6: {r: 0, g: 0, b: 0, a: 0} + key7: {r: 0, g: 0, b: 0, a: 0} + ctime0: 0 + ctime1: 65535 + ctime2: 0 + ctime3: 0 + ctime4: 0 + ctime5: 0 + ctime6: 0 + ctime7: 0 + atime0: 0 + atime1: 65535 + atime2: 0 + atime3: 0 + atime4: 0 + atime5: 0 + atime6: 0 + atime7: 0 + m_Mode: 0 + m_NumColorKeys: 2 + m_NumAlphaKeys: 2 + LineWidth: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 0.05 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + - serializedVersion: 2 + time: 1 + value: 0.05 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + WidthMultiplier: 0.1 + ColorOffset: 0 + WidthOffset: 0 + RotationOffset: 0 + StepMode: 0 + NumLineSteps: 10 + InterpolationMode: 1 + StepLength: 0.05 + MaxLineSteps: 2048 + StepLengthCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 1 + inSlope: 0 + outSlope: -0.5 + tangentMode: 0 + - serializedVersion: 2 + time: 1 + value: 0.5 + inSlope: -0.5 + outSlope: 0 + tangentMode: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + LineMaterial: {fileID: 2100000, guid: d9f5efc2f1dfc6846a9ebeac2f029eff, type: 2} + RoundedEdges: 1 + RoundedCaps: 1 + lineRenderer: {fileID: 0} +--- !u!114 &114599709742384530 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1071219928950220} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bec4b46028f8fb94c9b03b88fca37bd6, type: 3} + m_Name: + m_EditorClassIdentifier: + LineStartClamp: 0 + LineEndClamp: 1 + RotationType: 1 + FlipUpVector: 0 + OriginOffset: {x: 0, y: 0, z: 0} + ManualUpVectorBlend: 0 + ManualUpVectors: + - {x: 0, y: 1, z: 0} + - {x: 0, y: 1, z: 0} + - {x: 0, y: 1, z: 0} + VelocitySearchRange: 0.02 + VelocityBlend: 0.5 + DistortionType: 0 + DistortionStrength: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + - serializedVersion: 2 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + UniformDistortionStrength: 1 + distorters: [] + loops: 0 + Start: {x: 0, y: 0, z: 0} + End: {x: 1, y: 1, z: 1} +--- !u!114 &114864358960263782 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1071219928950220} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3be3fb966fbcc0f44add9a39d15cd3d0, type: 3} + m_Name: + m_EditorClassIdentifier: + distortOrder: 0 + distortStrength: 1 + LocalCenterOfGravity: {x: 0, y: 0, z: 0} + AxisStrength: {x: 1, y: 1, z: 1} + Radius: 0.5 + GravityStrength: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + - serializedVersion: 2 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 diff --git a/Assets/HoloToolkit/Input/Prefabs/LinearControllerPointer.prefab.meta b/Assets/HoloToolkit/Input/Prefabs/LinearControllerPointer.prefab.meta new file mode 100644 index 00000000000..210b4da0245 --- /dev/null +++ b/Assets/HoloToolkit/Input/Prefabs/LinearControllerPointer.prefab.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 7dd8661d4bacf2546a0237daef280291 +timeCreated: 1525392173 +licenseType: Pro +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HoloToolkit/Input/Scripts/Focus/FocusManager.cs b/Assets/HoloToolkit/Input/Scripts/Focus/FocusManager.cs index da97e6fd77b..4ffdfeb96aa 100644 --- a/Assets/HoloToolkit/Input/Scripts/Focus/FocusManager.cs +++ b/Assets/HoloToolkit/Input/Scripts/Focus/FocusManager.cs @@ -73,6 +73,8 @@ private void Update() [SerializeField] private float pointingExtent = 10f; + public float GlobalPointingExtent { get { return pointingExtent; } } + /// /// The LayerMasks, in prioritized order, that are used to determine the HitObject when raycasting. /// diff --git a/Assets/HoloToolkit/Input/Scripts/Focus/InputSourcePointer.cs b/Assets/HoloToolkit/Input/Scripts/Focus/InputSourcePointer.cs index 84840c430b6..29a243e11e0 100644 --- a/Assets/HoloToolkit/Input/Scripts/Focus/InputSourcePointer.cs +++ b/Assets/HoloToolkit/Input/Scripts/Focus/InputSourcePointer.cs @@ -5,6 +5,10 @@ using UnityEngine; using UnityEngine.EventSystems; +#if UNITY_WSA && UNITY_2017_2_OR_NEWER +using UnityEngine.XR.WSA.Input; +#endif + namespace HoloToolkit.Unity.InputModule { /// @@ -48,8 +52,12 @@ public bool InteractionEnabled public bool FocusLocked { get; set; } + public PointerLine PointerRay { get; set; } + private RayStep[] rays = new RayStep[1] { new RayStep(Vector3.zero, Vector3.forward) }; + private bool selectPressed = false; + [Obsolete("Will be removed in a later version. Use OnPreRaycast / OnPostRaycast instead.")] public void UpdatePointer() { @@ -65,11 +73,49 @@ public virtual void OnPreRaycast() { Debug.Assert(InputSource.SupportsInputInfo(InputSourceId, SupportedInputInfo.Pointing), string.Format("{0} with id {1} does not support pointing!", InputSource, InputSourceId)); +#if UNITY_WSA && UNITY_2017_2_OR_NEWER + // For visualization with controllers, we don't want to use the event-based data the InputManager has. + // Instead, we query the source states manually here. + InteractionSourceState[] currentReading = InteractionManager.GetCurrentReading(); + for (int i = 0; i < currentReading.Length; i++) + { + InteractionSourceState sourceState = currentReading[i]; + + if (sourceState.source.id != InputSourceId) + { + continue; + } + + selectPressed = sourceState.selectPressed; + + Vector3 position; + Vector3 forward; + + if (!sourceState.sourcePose.TryGetPosition(out position)) + { + return; + } + + if (!sourceState.sourcePose.TryGetForward(out forward, InteractionSourceNode.Pointer)) + { + return; + } + + if (CameraCache.Main.transform.parent != null) + { + position = CameraCache.Main.transform.parent.TransformPoint(position); + forward = CameraCache.Main.transform.parent.TransformDirection(forward); + } + + rays[0].CopyRay(new Ray(position, forward), FocusManager.Instance.GetPointingExtent(this)); + } +#else Ray pointingRay; if (InputSource.TryGetPointingRay(InputSourceId, out pointingRay)) { rays[0].CopyRay(pointingRay, FocusManager.Instance.GetPointingExtent(this)); } +#endif } if (RayStabilizer != null) @@ -81,7 +127,10 @@ public virtual void OnPreRaycast() public virtual void OnPostRaycast() { - // Nothing needed + if (PointerRay != null) + { + PointerRay.UpdateRenderedLine(rays, Result, selectPressed); + } } public bool OwnsInput(BaseEventData eventData) diff --git a/Assets/HoloToolkit/Input/Scripts/Focus/SimpleSinglePointerSelector.cs b/Assets/HoloToolkit/Input/Scripts/Focus/SimpleSinglePointerSelector.cs index 3056e7bc56b..c320a8ae90f 100644 --- a/Assets/HoloToolkit/Input/Scripts/Focus/SimpleSinglePointerSelector.cs +++ b/Assets/HoloToolkit/Input/Scripts/Focus/SimpleSinglePointerSelector.cs @@ -3,6 +3,10 @@ using UnityEngine; +#if UNITY_WSA && UNITY_2017_2_OR_NEWER +using UnityEngine.XR.WSA.Input; +#endif + namespace HoloToolkit.Unity.InputModule { /// @@ -31,6 +35,10 @@ public class SimpleSinglePointerSelector : MonoBehaviour, ISourceStateHandler, I private bool autoselectBestAvailable = false; public bool AutoselectBestAvailable { get { return autoselectBestAvailable; } set { autoselectBestAvailable = value; } } + [Tooltip("The line pointer prefab to use, if any.")] + [SerializeField] + private GameObject linePointerPrefab; + #endregion #region Data @@ -184,6 +192,11 @@ private void SetPointer(IPointingSource newPointer) } Debug.Assert(currentPointer != null, "No Pointer Set!"); + + if (IsGazePointerActive) + { + DetachInputSourcePointer(); + } } private void ConnectBestAvailablePointer() @@ -287,6 +300,32 @@ private void AttachInputSourcePointer(IInputSource inputSource, uint sourceId) inputSourcePointer.OwnAllInput = false; inputSourcePointer.ExtentOverride = null; inputSourcePointer.PrioritizedLayerMasksOverride = null; + + if (inputSourcePointer.PointerRay != null) + { + Destroy(inputSourcePointer.PointerRay.gameObject); + } + + if (inputSource is InteractionInputSource && linePointerPrefab != null) + { + inputSourcePointer.PointerRay = Instantiate(linePointerPrefab).GetComponent(); + inputSourcePointer.PointerRay.ExtentOverride = Cursor.DefaultCursorDistance; + Handedness handedness; + if (((InteractionInputSource)inputSource).TryGetHandedness(sourceId, out handedness)) + { +#if UNITY_WSA && UNITY_2017_2_OR_NEWER + inputSourcePointer.PointerRay.Handedness = (InteractionSourceHandedness)handedness; +#endif + } + } + } + + private void DetachInputSourcePointer() + { + if (inputSourcePointer.PointerRay != null) + { + Destroy(inputSourcePointer.PointerRay.gameObject); + } } private bool IsInputSourcePointerActive diff --git a/Assets/HoloToolkit/Input/Scripts/InputSources/InteractionInputSource.cs b/Assets/HoloToolkit/Input/Scripts/InputSources/InteractionInputSource.cs index 26b25b94f97..b93dc8ff0b1 100644 --- a/Assets/HoloToolkit/Input/Scripts/InputSources/InteractionInputSource.cs +++ b/Assets/HoloToolkit/Input/Scripts/InputSources/InteractionInputSource.cs @@ -4,12 +4,12 @@ using UnityEngine; #if UNITY_WSA +using System.Collections.Generic; #if UNITY_2017_2_OR_NEWER using UnityEngine.XR.WSA.Input; #else using UnityEngine.VR.WSA.Input; #endif -using System.Collections.Generic; #endif namespace HoloToolkit.Unity.InputModule @@ -451,6 +451,21 @@ public void StopHaptics(uint sourceId) #endif } + public bool TryGetHandedness(uint sourceId, out Handedness handedness) + { +#if UNITY_WSA && UNITY_2017_2_OR_NEWER + SourceData sourceData; + if (sourceIdToData.TryGetValue(sourceId, out sourceData)) + { + handedness = (Handedness)sourceData.Handedness; + return true; + } +#endif + + handedness = default(Handedness); + return false; + } + #region BaseInputSource implementations public override SupportedInputInfo GetSupportedInputInfo(uint sourceId) @@ -667,7 +682,6 @@ private SupportedInputInfo GetSupportFlag(SourceCapability c #endregion #if UNITY_WSA - /// /// Gets the source data for the specified interaction source if it already exists, otherwise creates it. /// diff --git a/Assets/HoloToolkit/Input/Scripts/Utilities/AttachToController.cs b/Assets/HoloToolkit/Input/Scripts/Utilities/AttachToController.cs index 29b1b28343d..91c8592ede5 100644 --- a/Assets/HoloToolkit/Input/Scripts/Utilities/AttachToController.cs +++ b/Assets/HoloToolkit/Input/Scripts/Utilities/AttachToController.cs @@ -33,15 +33,7 @@ protected override void OnEnable() { SetChildrenActive(false); -#if UNITY_WSA && UNITY_2017_2_OR_NEWER - // Look if the controller has loaded. - if (MotionControllerVisualizer.Instance.TryGetControllerModel(Handedness, out ControllerInfo)) - { - AddControllerTransform(ControllerInfo); - } - MotionControllerVisualizer.Instance.OnControllerModelLoaded += AddControllerTransform; - MotionControllerVisualizer.Instance.OnControllerModelUnloaded += RemoveControllerTransform; -#endif + base.OnEnable(); } protected override void AddControllerTransform(MotionControllerInfo newController) @@ -51,8 +43,6 @@ protected override void AddControllerTransform(MotionControllerInfo newControlle { base.AddControllerTransform(newController); - SetChildrenActive(true); - // Parent ourselves under the element and set our offsets transform.parent = ElementTransform; transform.localPosition = PositionOffset; @@ -63,6 +53,8 @@ protected override void AddControllerTransform(MotionControllerInfo newControlle transform.localScale = ScaleOffset; } + SetChildrenActive(true); + // Announce that we're attached OnAttachToController(); @@ -80,10 +72,10 @@ protected override void RemoveControllerTransform(MotionControllerInfo oldContro OnDetachFromController(); - transform.parent = null; - SetChildrenActive(false); + transform.parent = null; + IsAttached = false; } #endif diff --git a/Assets/HoloToolkit/Input/Scripts/Utilities/BaseControllerPointer.cs b/Assets/HoloToolkit/Input/Scripts/Utilities/BaseControllerPointer.cs new file mode 100644 index 00000000000..5f289dd3407 --- /dev/null +++ b/Assets/HoloToolkit/Input/Scripts/Utilities/BaseControllerPointer.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using HoloToolkit.Unity.InputModule; +using UnityEngine; + +public abstract class BaseControllerPointer : AttachToController +{ + [SerializeField] + [Range(0f, 360f)] + protected float CurrentPointerOrientation; + + [SerializeField] + [Range(0.5f, 50f)] + private float extentOverride = 2f; + + [SerializeField] + [Tooltip("Source transform for raycast origin - leave null to use default transform")] + protected Transform RaycastOrigin; + + public float? ExtentOverride + { + get { return extentOverride; } + set { extentOverride = value ?? FocusManager.Instance.GlobalPointingExtent; } + } + + /// + /// The Y orientation of the pointer target - used for touchpad rotation and navigation + /// + public virtual float PointerOrientation + { + get + { + return CurrentPointerOrientation + (RaycastOrigin != null ? RaycastOrigin.eulerAngles.y : transform.eulerAngles.y); + } + set + { + CurrentPointerOrientation = value; + } + } + + /// + /// The forward direction of the targeting ray + /// + public virtual Vector3 PointerDirection + { + get { return RaycastOrigin != null ? RaycastOrigin.forward : transform.forward; } + } +} diff --git a/Assets/HoloToolkit/Input/Scripts/Utilities/BaseControllerPointer.cs.meta b/Assets/HoloToolkit/Input/Scripts/Utilities/BaseControllerPointer.cs.meta new file mode 100644 index 00000000000..5b84cd0c3bc --- /dev/null +++ b/Assets/HoloToolkit/Input/Scripts/Utilities/BaseControllerPointer.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 8014ae724f8552b4b91da7104fc1769f +timeCreated: 1525892837 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HoloToolkit/Input/Scripts/Utilities/ControllerFinder.cs b/Assets/HoloToolkit/Input/Scripts/Utilities/ControllerFinder.cs index 0ff5202031d..fa775a3dc3b 100644 --- a/Assets/HoloToolkit/Input/Scripts/Utilities/ControllerFinder.cs +++ b/Assets/HoloToolkit/Input/Scripts/Utilities/ControllerFinder.cs @@ -37,6 +37,8 @@ public InteractionSourceHandedness Handedness private Transform elementTransform; protected MotionControllerInfo ControllerInfo; + + private bool started = false; #endif protected virtual void OnEnable() @@ -48,16 +50,24 @@ protected virtual void OnEnable() return; } - // Look if the controller has loaded. - if (MotionControllerVisualizer.Instance.TryGetControllerModel(handedness, out ControllerInfo)) + if (started) { - AddControllerTransform(ControllerInfo); + CheckModelAlreadyLoaded(); } + MotionControllerVisualizer.Instance.OnControllerModelLoaded += AddControllerTransform; MotionControllerVisualizer.Instance.OnControllerModelUnloaded += RemoveControllerTransform; #endif } + protected virtual void Start() + { +#if UNITY_WSA && UNITY_2017_2_OR_NEWER + CheckModelAlreadyLoaded(); + started = true; +#endif + } + protected virtual void OnDisable() { #if UNITY_WSA && UNITY_2017_2_OR_NEWER @@ -83,7 +93,7 @@ protected virtual void OnDestroy() protected virtual void AddControllerTransform(MotionControllerInfo newController) { #if UNITY_WSA && UNITY_2017_2_OR_NEWER - if (newController.Handedness == handedness) + if (newController.Handedness == handedness && !newController.Equals(ControllerInfo)) { if (!newController.TryGetElement(element, out elementTransform)) { @@ -106,6 +116,27 @@ protected virtual void RemoveControllerTransform(MotionControllerInfo oldControl ControllerInfo = null; ElementTransform = null; } +#endif + } + + /// + /// Look if the controller was already loaded. This could happen if the + /// GameObject was instantiated at runtime and the model loaded event has already fired. + /// + private void CheckModelAlreadyLoaded() + { + if (!MotionControllerVisualizer.ConfirmInitialized()) + { + // The motion controller visualizer singleton could not be found. + return; + } + +#if UNITY_WSA && UNITY_2017_2_OR_NEWER + MotionControllerInfo newController; + if (MotionControllerVisualizer.Instance.TryGetControllerModel(handedness, out newController)) + { + AddControllerTransform(newController); + } #endif } } diff --git a/Assets/HoloToolkit/Input/Scripts/Utilities/PointerLine.cs b/Assets/HoloToolkit/Input/Scripts/Utilities/PointerLine.cs new file mode 100644 index 00000000000..769a7c99bfe --- /dev/null +++ b/Assets/HoloToolkit/Input/Scripts/Utilities/PointerLine.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using HoloToolkit.Unity.UX; +using UnityEngine; + +namespace HoloToolkit.Unity.InputModule +{ + [RequireComponent(typeof(DistorterGravity))] + [RequireComponent(typeof(LineBase))] + [RequireComponent(typeof(LineRendererBase))] + public class PointerLine : BaseControllerPointer + { + [Header("Colors")] + [SerializeField] + [GradientDefault(GradientDefaultAttribute.ColorEnum.Blue, GradientDefaultAttribute.ColorEnum.White, 1f, 0.25f)] + protected Gradient LineColorSelected; + + [SerializeField] + [GradientDefault(GradientDefaultAttribute.ColorEnum.Blue, GradientDefaultAttribute.ColorEnum.White, 1f, 0.5f)] + protected Gradient LineColorValid; + + [SerializeField] + [GradientDefault(GradientDefaultAttribute.ColorEnum.Gray, GradientDefaultAttribute.ColorEnum.White, 1f, 0.5f)] + protected Gradient LineColorNoTarget; + + [Range(5, 100)] + [SerializeField] + protected int LineCastResolution = 25; + + [SerializeField] + protected LineBase LineBase; + + [SerializeField] + [Tooltip("If no line renderers are specified, this array will be auto-populated on startup.")] + protected LineRendererBase[] LineRenderers; + + protected DistorterGravity DistorterGravity; + + /// + /// Line pointer stays inactive until it's attached to a controller. + /// + public bool InteractionEnabled + { + get + { +#if UNITY_WSA && UNITY_2017_2_OR_NEWER + return ControllerInfo != null; +#else + return false; +#endif + } + } + + protected override void OnEnable() + { + base.OnEnable(); + + LineBase = GetComponent(); + DistorterGravity = GetComponent(); + LineBase.AddDistorter(DistorterGravity); + if (LineRenderers == null || LineRenderers.Length == 0) + { + LineRenderers = LineBase.GetComponentsInChildren(); + } + + LineBase.enabled = false; + } + + public void UpdateRenderedLine(RayStep[] lines, PointerResult result, bool selectPressed) + { + if (LineBase == null) { return; } + + Gradient lineColor = LineColorNoTarget; + + if (InteractionEnabled) + { + LineBase.enabled = true; + + // If we hit something + if (result.End.Object != null) + { + lineColor = LineColorValid; + LineBase.LastPoint = result.End.Point; + } + else + { + LineBase.LastPoint = RayStep.GetPointByDistance(lines, ExtentOverride.Value); + } + + if (selectPressed) + { + lineColor = LineColorSelected; + } + } + else + { + LineBase.enabled = false; + } + + for (int i = 0; i < LineRenderers.Length; i++) + { + LineRenderers[i].LineColor = lineColor; + } + } + } +} diff --git a/Assets/HoloToolkit/Input/Scripts/Utilities/PointerLine.cs.meta b/Assets/HoloToolkit/Input/Scripts/Utilities/PointerLine.cs.meta new file mode 100644 index 00000000000..28b48a2ce6b --- /dev/null +++ b/Assets/HoloToolkit/Input/Scripts/Utilities/PointerLine.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: df317dc594e50444da58008aa4ee1475 +timeCreated: 1522092957 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HoloToolkit/UX/Scripts/Lines/LineUnity.cs b/Assets/HoloToolkit/UX/Scripts/Lines/LineUnity.cs index 0174e3d34ac..fdc336b88e6 100644 --- a/Assets/HoloToolkit/UX/Scripts/Lines/LineUnity.cs +++ b/Assets/HoloToolkit/UX/Scripts/Lines/LineUnity.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. -using HoloToolkit.Unity; using System.Collections; using UnityEngine;