The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
Voice to show/hide cursor?
I'm using the HL with a model built in layers, like an onion. I was able to borrow the cursor from Origami tutorial along with associated scripts to move the model and show/hide each of five layers, using voice commands. But the same script doesn't show / hide the cursor. The cursor is in root of hierarchy in Unity 5 as in the Origami setup. Can anyone suggest what needs to change to show/hide the cursor?
The same script works for layers, but not for the cursor:
Code is:
keywords.Add("Show cursor", () =>
{
this.BroadcastMessage("OnShowCursor");
});
keywords.Add("Hide cursor", () => { this.BroadcastMessage("OnHideCursor"); });
To show/hide I'm using:
public void OnShowCursor()
{
rend = GetComponent();
rend.enabled = true;
}
public void OnHideCursor() { rend = GetComponent<Renderer>(); rend.enabled = false; }
Carol LaFayette
Harold L. Adams Interdisciplinary Professor, Department of Visualization
Director, Institute for Applied Creativity
SEAD network
Texas A&M University
Best Answers
-
OptionsHoloSheep mod
@clafayette if you also borrowed the WorldCursor.cs script from the origami project, you will probably want to add you OnShowCursor and OnHideCursor handlers to that script.
They should set a variable inside the handlers that you would then work into the conditional logic inside the WorldCursor "Update" routine logic that would only execute the meshRenderer.enabled = true; section when your cursor is being shown.
For example something like the following untested code might work:
using UnityEngine; public class WorldCursor : MonoBehaviour { private MeshRenderer meshRenderer; private bool ShowCursor; void Start() { // Grab the mesh renderer that's on the same object as this script. meshRenderer = this.gameObject.GetComponentInChildren<MeshRenderer>(); } public void OnShowCursor() { ShowCursor = true; } public void OnHideCursor() { ShowCursor = false; } // Update is called once per frame void Update() { // Do a raycast into the world based on the user's // head position and orientation. var headPosition = Camera.main.transform.position; var gazeDirection = Camera.main.transform.forward; RaycastHit hitInfo; if (Physics.Raycast(headPosition, gazeDirection, out hitInfo) && ShowCursor == true) { // If the raycast hit a hologram... // Display the cursor mesh. meshRenderer.enabled = true; // Move the cursor to the point where the raycast hit. this.transform.position = hitInfo.point; // Rotate the cursor to hug the surface of the hologram. this.transform.rotation = Quaternion.FromToRotation(Vector3.up, hitInfo.normal); } else { // If the raycast did not hit a hologram, hide the cursor mesh. meshRenderer.enabled = false; } } }
Windows Holographic User Group Redmond
WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
WinHUGR YouTube Channel -- live streamed meetings6 -
Options
Thanks HoloSheep, this worked nicely! I added ShowCursor = true; to WorldCursor, above, to show the cursor on start.
void Start() { // Grab the mesh renderer that's on the same object as this script. meshRenderer = this.gameObject.GetComponentInChildren<MeshRenderer>(); ShowCursor = true;
Carol LaFayette
Harold L. Adams Interdisciplinary Professor, Department of Visualization
Director, Institute for Applied Creativity
SEAD network
Texas A&M University5
Answers
@clafayette if you also borrowed the WorldCursor.cs script from the origami project, you will probably want to add you OnShowCursor and OnHideCursor handlers to that script.
They should set a variable inside the handlers that you would then work into the conditional logic inside the WorldCursor "Update" routine logic that would only execute the meshRenderer.enabled = true; section when your cursor is being shown.
For example something like the following untested code might work:
Windows Holographic User Group Redmond
WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
WinHUGR YouTube Channel -- live streamed meetings
Thanks HoloSheep, this worked nicely! I added ShowCursor = true; to WorldCursor, above, to show the cursor on start.
Carol LaFayette
Harold L. Adams Interdisciplinary Professor, Department of Visualization
Director, Institute for Applied Creativity
SEAD network
Texas A&M University