Skip to content

Commit bf90728

Browse files
committed
Fixes for URP
1 parent 528eb19 commit bf90728

File tree

12 files changed

+552
-496
lines changed

12 files changed

+552
-496
lines changed

Assets/SteamVR/InteractionSystem/Core/Scripts/Hand.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,24 @@ protected virtual void UpdateHovering()
888888
hoveringInteractable = closestInteractable;
889889
}
890890

891+
public Vector3 GetHoverPosition()
892+
{
893+
if (useControllerHoverComponent && mainRenderModel != null && mainRenderModel.IsControllerVisibile())
894+
{
895+
return mainRenderModel.GetControllerPosition(controllerHoverComponent);
896+
}
897+
else if (useHoverSphere)
898+
{
899+
return hoverSphereTransform.position;
900+
}
901+
else if (useFingerJointHover && mainRenderModel != null && mainRenderModel.IsHandVisibile())
902+
{
903+
return mainRenderModel.GetBonePosition((int)fingerJointHover);
904+
}
905+
906+
return this.transform.position;
907+
}
908+
891909
protected virtual bool CheckHoveringForTransform(Vector3 hoverPosition, float hoverRadius, ref float closestDistance, ref Interactable closestInteractable, Color debugColor)
892910
{
893911
bool foundCloser = false;

Assets/SteamVR/InteractionSystem/Core/Scripts/InputModule.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
using UnityEngine;
88
using System.Collections;
99
using UnityEngine.EventSystems;
10+
11+
#if ENABLE_INPUT_SYSTEM
1012
using UnityEngine.InputSystem.UI;
13+
#endif
1114

1215
namespace Valve.VR.InteractionSystem
1316
{

Assets/SteamVR/InteractionSystem/Core/Scripts/Interactable.cs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ public Hand hoveringHand
9393
public bool wasHovering { get; protected set; }
9494

9595

96+
private bool hasWaveOrigin = false;
97+
private int waveOriginID = int.MinValue;
98+
9699
private void Awake()
97100
{
98101
skeletonPoser = GetComponent<SteamVR_Skeleton_Poser>();
@@ -101,11 +104,8 @@ private void Awake()
101104
protected virtual void Start()
102105
{
103106
if (highlightMat == null)
104-
#if UNITY_URP
105-
highlightMat = (Material)Resources.Load("SteamVR_HoverHighlight_URP", typeof(Material));
106-
#else
107107
highlightMat = (Material)Resources.Load("SteamVR_HoverHighlight", typeof(Material));
108-
#endif
108+
hasWaveOrigin = highlightMat.HasProperty(waveOriginID);
109109

110110
if (highlightMat == null)
111111
Debug.LogError("<b>[SteamVR Interaction]</b> Hover Highlight Material is missing. Please create a material named 'SteamVR_HoverHighlight' and place it in a Resources folder", this);
@@ -261,6 +261,31 @@ protected virtual void OnHandHoverBegin(Hand hand)
261261
}
262262

263263

264+
protected virtual void HandHoverUpdate(Hand hand)
265+
{
266+
if (hasWaveOrigin)
267+
{
268+
Vector3 hoverPosition = hand.GetHoverPosition();
269+
270+
for (int rendererIndex = 0; rendererIndex < highlightRenderers.Length; rendererIndex++)
271+
{
272+
for (int materialIndex = 0; materialIndex < highlightRenderers[rendererIndex].sharedMaterials.Length; materialIndex++)
273+
{
274+
highlightRenderers[rendererIndex].sharedMaterials[materialIndex].SetVector(waveOriginID, hoverPosition);
275+
}
276+
}
277+
278+
for (int rendererIndex = 0; rendererIndex < highlightSkinnedRenderers.Length; rendererIndex++)
279+
{
280+
for (int materialIndex = 0; materialIndex < highlightSkinnedRenderers[rendererIndex].sharedMaterials.Length; materialIndex++)
281+
{
282+
highlightSkinnedRenderers[rendererIndex].sharedMaterials[materialIndex].SetVector(waveOriginID, hoverPosition);
283+
}
284+
}
285+
}
286+
}
287+
288+
264289
/// <summary>
265290
/// Called when a Hand stops hovering over this object
266291
/// </summary>

0 commit comments

Comments
 (0)