Hello everyone.

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.
Options

Script runs in Unity Preview but not on HoloLens

I'm new to C#, HoloLens, and Unity. I want to add the voice command functionality from Holograms 101 to Holograms 230.

Having completed Holograms 230, I've taken the SpeechManager script from Holograms 101, added some Debug.Log commands, and dragged it onto an object in Unity's "Hierarchy" panel. When I click the "Play" button in Unity, my script runs (as verified by the fact that my Debug.Log appears in the status bar). But when I build and deploy it to the HoloLens (via "Debug -> Start Debugging" in Visual Studio), the Debug.Logs from my new script don't show up in Visual Studio's "Output" panel, even through Debug.Logs from other scripts do.

Here's my SpeechManager.cs:

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Windows.Speech;

public class SpeechManager : MonoBehaviour {

    KeywordRecognizer keywordRecognizer = null;
    Dictionary<string, System.Action> keywords = new Dictionary<string, System.Action>();

    // Use this for initialization
    void Start () {
        Debug.Log("!!Starting speech manager");
        keywords.Add("Place item", () =>
        {
            Debug.Log("!!Place item");
        });

        // Tell the KeywordRecognizer about our keywords.
        keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());

        // Register a callback for the KeywordRecognizer and start recognizing!
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
        keywordRecognizer.Start();
    }

    private void KeywordRecognizer_OnPhraseRecognized(PhraseRecognizedEventArgs args)
    {
        System.Action keywordAction;
        if (keywords.TryGetValue(args.text, out keywordAction))
        {
            keywordAction.Invoke();
        }
    }
}

Answers

Sign In or Register to comment.