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.

Keywordmanager.cs Adding a keyword dynamically in script

SpheredCazualSpheredCazual ✭✭
edited October 2016 in Questions And Answers

Hi

I have manage to add the keyword dynamuically in my script but keep getting an error when adding a listener to a function (namely NullReferenceException: Object reference not set to an instance of an object) in the last line in the below code, obviously i am doing something wrong but cannot fathom what? any ideas would be welcome.

 // Add name, action to Keywordmanager
           GameObject go = GameObject.Find("Managers");
            KeywordManager km = go.GetComponent<KeywordManager>();

            GroupResize(km.KeywordsAndResponses.Length+1, ref km.KeywordsAndResponses );

            moveToCamera mtc = myCurrentBinder[i].GetComponent<moveToCamera>();

            km.KeywordsAndResponses[km.KeywordsAndResponses.Length-1].Keyword = binderAttributes[1];

// UnityEvent ue = new UnityEvent();
//
// ue.AddListener(() => mtc.moveNow());
//
// km.KeywordsAndResponses[km.KeywordsAndResponses.Length-1].Response = ue;

            km.KeywordsAndResponses[km.KeywordsAndResponses.Length-1].Response.AddListener(() => mtc.moveNow());

creative mind, free thinker, dreamer, maker, mostly working on games and doodling around with gadgets, Sphered Cazual/Elite/Master of the Universe/Dad/Husband @mariovermeulen

Tagged:

Answers

  • Does anyone have an idea what I am doing wrong?

    creative mind, free thinker, dreamer, maker, mostly working on games and doodling around with gadgets, Sphered Cazual/Elite/Master of the Universe/Dad/Husband @mariovermeulen

Sign In or Register to comment.