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

Visual Feedback around Cursor

Hey,

I am trying to show visual feedback after voice commands around the cursor.
I use the keyword manager from the HoloToolkit to pick up the commands.

I have a working solution, but I am not sure whether there might be a better i.e. more efficient method.

I wrote the "SendFeedback.cs"-Script to handle the feedback. This script is attached to a GameObject which also has a script to take action when the keyword was recognized - let's call this script "FeedbackTest.cs".

In Unity I attache a Prefab to the "FeedbackAsset" property and the cursor to the "FeedbackParent"-Property.

Is this a good concept to handle visual feedback? Or is there a simpler way which I have missed?

Thanks in advanced.

SendFeedback.cs
using UnityEngine;

        public class SendFeedback : MonoBehaviour
        {

            [Tooltip("Feedack Prefab Asset.")]
            public GameObject FeedbackAsset;
            private GameObject feedbackGameObject;

            [Tooltip("Prefab to Parent the Prefab")]
            public GameObject FeedbackParent;

            [Tooltip("Time to display the feedback Asset.")]
            public float DisplayTime = 2.0f;


            delegate void FeedbackDelegate();
            FeedbackDelegate feedbackDelegate;

            private void Awake()
            {
                if (FeedbackAsset != null && FeedbackParent != null)
                {
                    feedbackGameObject = GameObject.Instantiate(FeedbackAsset);
                    feedbackGameObject.transform.parent = FeedbackParent.transform;
                    feedbackGameObject.SetActive(false);

                    feedbackDelegate = InvokeFeedback;
                }
                else
                {
                    Debug.Log("No Feedback Asset and/or Feedback parent assigned!");
                    Destroy(this);
                }
            }

            public void SendFeedbackInvoke()
            {
                feedbackDelegate();
            }

            private void InvokeFeedback()
            {
                ShowFeedback();
                Invoke("HideFeedback", DisplayTime);
            }

            private void ShowFeedback()
            {
                if (feedbackGameObject != null)
                {
                    feedbackGameObject.SetActive(true);
                }
            }

            private void HideFeedback()
            {
                if (feedbackGameObject != null)
                {
                    feedbackGameObject.SetActive(false);
                }
            }

        }

SendFeedback.cs

using UnityEngine;

public class FeedbackTest : MonoBehaviour {

    private SendFeedback sendFeedback;

    private void Awake()
    {
        sendFeedback = GetComponent<SendFeedback>();
    }

    public void KeywordHeard()
    {
        sendFeedback.SendFeedbackInvoke();

        // Do other stuff here...

    }
}

Best Answers

  • Options
    HoloFanHoloFan
    Answer ✓

    Thank you for your answer. It sounds quit good. I like the idea of creating new states and assigning custom visuals for these states.
    But I think I will use my method as I don't want to keep track of all scripts sending feedback in my Cursor-GameObject.

Answers

  • Options
    HoloFanHoloFan
    Answer ✓

    Thank you for your answer. It sounds quit good. I like the idea of creating new states and assigning custom visuals for these states.
    But I think I will use my method as I don't want to keep track of all scripts sending feedback in my Cursor-GameObject.

Sign In or Register to comment.