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

HoloToolKit KeywordManager

Hello,
Can someone give me reference to what code I would use to hide and unhide a gameobject and its children using Holotoolkit keywordmanager?
I have used this in the past and it has worked but now it does not:

using System.Collections.Generic;
using HoloToolkit.Unity;
using UnityEngine;

public class HideLayer : MonoBehaviour
{
public void showHidePlane()
{
if(GetComponent().enabled == true)
{
GetComponent().enabled = false;
}
else
{
GetComponent().enabled = true;
}
}
}

Thanks!

Tagged:

Best Answer

  • Options
    holonutholonut
    Answer ✓

    I am sorry. I was just looking through my threads and I noticed that I did not respond back to you! This definitely did the trick! Thank you for your time!!

Answers

  • Options

    Hey
    The script below should do the trick. Please make sure to have an SpeechInputSource in your scene. As an alternative you could also add an SpeechInputHandler to your scene and specify the method "ToggleLayer" there as an event.

    using UnityEngine;
    using HoloToolkit.Unity.InputModule;
    
    public class HideLayer : MonoBehaviour, ISpeechHandler
    {
      public GameObject ObjectToHide;
      public string Keyword;
    
      private void OnSpeechKeywordRecognized(SpeechKeywordRecognizedEventData eventData)
      {
        if(eventData.RecognizedText == Keyword)
          ToggleLayer();
      }
    
      public void ToggleLayer()
      {
        ObjectToHide.SetActive(!ObjectToHide.activeSelf);
      }
    }
    
  • Options
    holonutholonut
    Answer ✓

    I am sorry. I was just looking through my threads and I noticed that I did not respond back to you! This definitely did the trick! Thank you for your time!!

Sign In or Register to comment.