Skip to content

Commit

Permalink
Adding far away hand interaction
Browse files Browse the repository at this point in the history
Adding switch between laser interaction and hand interacton with pinch gesture.
  • Loading branch information
FelixRoh committed Sep 5, 2021
1 parent ae131a0 commit 1d13a52
Show file tree
Hide file tree
Showing 10 changed files with 1,697 additions and 211 deletions.
174 changes: 91 additions & 83 deletions Nreal/Assets/NRSDK/Models/Hands/HandJoint/SphereJoint.prefab
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
%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_SourcePrefab: {fileID: 0}
m_RootGameObject: {fileID: 1292187076706152}
m_IsPrefabAsset: 1
--- !u!1 &1292187076706152
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4590301643461410}
Expand All @@ -29,28 +19,12 @@ GameObject:
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1943492813550636
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 6
m_Component:
- component: {fileID: 4610044817108114}
- component: {fileID: 33924752770114610}
- component: {fileID: 23420751684691154}
m_Layer: 0
m_Name: Axis
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4590301643461410
Transform:
m_ObjectHideFlags: 1
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1292187076706152}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
Expand All @@ -60,42 +34,42 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4610044817108114
Transform:
m_ObjectHideFlags: 1
--- !u!33 &33618516296970838
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1943492813550636}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.12, y: 0.12, z: 0.12}
m_Children: []
m_Father: {fileID: 4590301643461410}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &23420751684691154
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1292187076706152}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &23594847399696500
MeshRenderer:
m_ObjectHideFlags: 1
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1943492813550636}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1292187076706152}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 4294967295
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 83533d396a6e3a042a637f7a7c198d6f, type: 2}
- {fileID: 2100000, guid: 80c308f79a5ad3c489687e70fcff316b, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
Expand All @@ -108,29 +82,88 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!23 &23594847399696500
MeshRenderer:
m_ObjectHideFlags: 1
m_AdditionalVertexStreams: {fileID: 0}
--- !u!135 &135550654450833540
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1292187076706152}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 0
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
--- !u!1 &1943492813550636
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4610044817108114}
- component: {fileID: 33924752770114610}
- component: {fileID: 23420751684691154}
m_Layer: 0
m_Name: Axis
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &4610044817108114
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1943492813550636}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.12, y: 0.12, z: 0.12}
m_Children: []
m_Father: {fileID: 4590301643461410}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &33924752770114610
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1943492813550636}
m_Mesh: {fileID: 4300000, guid: 3c735a14671f45b438734f07c7774f29, type: 3}
--- !u!23 &23420751684691154
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1943492813550636}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 4294967295
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 80c308f79a5ad3c489687e70fcff316b, type: 2}
- {fileID: 2100000, guid: 83533d396a6e3a042a637f7a7c198d6f, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
Expand All @@ -143,29 +176,4 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &33618516296970838
MeshFilter:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1292187076706152}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &33924752770114610
MeshFilter:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1943492813550636}
m_Mesh: {fileID: 4300000, guid: 3c735a14671f45b438734f07c7774f29, type: 3}
--- !u!135 &135550654450833540
SphereCollider:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1292187076706152}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 0
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
m_AdditionalVertexStreams: {fileID: 0}
42 changes: 40 additions & 2 deletions Nreal/Assets/NrealExtensions/NRExtButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,36 @@
using UnityEngine.UI;
using NRKernal;

/// <summary>
/// Extent the button inside the "Laser-Mode" with userfeedback
/// </summary>
[RequireComponent(typeof(Button))]
public class NRExtButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerDownHandler, IPointerUpHandler
{

/// <summary>
/// Text element of the button
/// </summary>
Text txt;

/// <summary>
/// Base color of button
/// </summary>
Color baseColor;

/// <summary>
/// Button gameobject
/// </summary>
Button btn;

/// <summary>
/// Delay to remove wrong events
/// </summary>
bool interactableDelay;

/// <summary>
/// Start methode of unity gameobject
/// </summary>
void Start()
{
txt = GetComponentInChildren<Text>();
Expand All @@ -21,6 +42,9 @@ void Start()
interactableDelay = btn.interactable;
}

/// <summary>
/// Update methode of unity gameobject
/// </summary>
void Update()
{
if (btn.interactable != interactableDelay)
Expand All @@ -37,11 +61,14 @@ void Update()
interactableDelay = btn.interactable;
}

/// <summary>
/// Event reciver methode which triggered if the laser cross/ enters the button
/// </summary>
/// <param name="eventData"></param>
public void OnPointerEnter(PointerEventData eventData)
{
if (btn.interactable)
{
NRInput.TriggerHapticVibration();
{
txt.color = baseColor * btn.colors.highlightedColor * btn.colors.colorMultiplier;
}
else
Expand All @@ -50,10 +77,14 @@ public void OnPointerEnter(PointerEventData eventData)
}
}

/// <summary>
/// Event reciver methode which triggered if a button of the controller is pressed
/// </summary>
public void OnPointerDown(PointerEventData eventData)
{
if (btn.interactable)
{
NRInput.TriggerHapticVibration();
txt.color = baseColor * btn.colors.pressedColor * btn.colors.colorMultiplier;
}
else
Expand All @@ -62,6 +93,9 @@ public void OnPointerDown(PointerEventData eventData)
}
}

/// <summary>
/// Event reciver methode which triggered if leaves the pressmode
/// </summary>
public void OnPointerUp(PointerEventData eventData)
{
if (btn.interactable)
Expand All @@ -74,6 +108,10 @@ public void OnPointerUp(PointerEventData eventData)
}
}

/// <summary>
/// Event reciver methode which triggered if the laser leaves the button
/// </summary>
/// <param name="eventData"></param>
public void OnPointerExit(PointerEventData eventData)
{
if (btn.interactable)
Expand Down
Loading

0 comments on commit 1d13a52

Please sign in to comment.