How to hide the cursor in hololens2?
I need to use handray, and get the hit point coordinate to set my gameobject position like
GameObject manipulatePoint
foreach (var source in CoreServices.InputSystem.DetectedInputSources)
{
if (source.SourceType is InputSourceType.Hand)
{
foreach (var p in source.Pointers)
{
if (p is ShellHandRayPointer && p.Result != null)
{
if (p.PointerName == "Right_ShellHandRayPointer(Clone)")
{
var endPoint = p.Result.Details.Point;
var hitObject = p.Result.Details.Object;
if (hitObject != null)
{
var rayPosition = p.Result.Details.Point;
var rayNormal = p.Result.Details.Normal;
manipulatePoint.transform.position = rayPosition;
}
}
}
}
}
}
But there is a default cursor show on the intersection of ray and object. Is there any method to hide the cursor (hide by script, or edit the default cursor). Thanks.
I tried to make my hand ray, but result is not as expected. I don't know how to make vector forward like MRTK handray.
You can customize the hand ray prefab in MRTK Profile/Input/Pointers. DefaultHoloLens2ConfigurationProfile uses ShellHandRayPointer as the hand ray prefab by default, and DefaultGazeCursor is used as the cursor prefab by default. Feel free to delete or replace it. Please refer to Pointers - MRTK 2 | Microsoft Learn for more information.
Regarding making hand rays, have you tried Raycast - Unity - Scripting API: Physics.Raycast (unity3d.com)?