Hello everyone.

We have decided to phase out the Mixed Reality Forums over the next few months in favor of other ways to connect with us.

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.

The plan between now and the beginning of May is to clean up old, unanswered questions that are no longer relevant. The forums will remain open and usable.

On May 1st we will be locking the forums to new posts and replies. They will remain available for another three months for the purposes of searching them, and then they will be closed altogether on August 1st.

So, where does that leave our awesome community to ask questions? Well, there are a few places we want to engage with you. 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. And always feel free to hit us up on Twitter @MxdRealityDev.

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.