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

Holograms-210-Gaze GazeStabilizer

I am carefully following "Chapter 2 - Cursor and target feedback" of Holograms 210.

At the point where both my GazeManager.cs and CursorManager.cs are complete (having confirmed their correctness) I get a "NullReferenceException" error every frame.

Through logging debug messages, I found the cause: GazeStabilizer being null...

Given that I get this component in the GazeManager script that is attached to an empty game object called Managers, I wonder why the component is not gotten!

The following are the only 2 lines that get this component, so I wonder what I am missing? What else should I be doing to get this component? I don't think I have missed any steps in the tutorial...

    private GazeStabilizer gazeStabilizer;

    void Awake()
     {
            // Get a 'GazeStabilizer' component and assign it to gazeStabilizer.
            gazeStabilizer = GetComponent<GazeStabilizer>();

            if (gazeStabilizer == null) Debug.Log("Here!");
      }
Tagged:

Best Answer

  • Options
    stepan_stulovstepan_stulov ✭✭✭
    Answer ✓

    Hey, @hmiri

    Given that I get this component in the GazeManager script that is attached to an empty game object called Managers, I wonder why the component is not gotten!

    You answered your question yourself. GetComponent() returns null because GazeStabilizer component is not added to the game object. Simply add it.

    Calling GetComponent is actually calling gameObject.GetComponent(). So it tries to retrieve the component from the game object that the caller itself is a component on. If it's not there you get null.

    Building the future of holographic navigation. We're hiring.

Answers

  • Options
    stepan_stulovstepan_stulov ✭✭✭
    Answer ✓

    Hey, @hmiri

    Given that I get this component in the GazeManager script that is attached to an empty game object called Managers, I wonder why the component is not gotten!

    You answered your question yourself. GetComponent() returns null because GazeStabilizer component is not added to the game object. Simply add it.

    Calling GetComponent is actually calling gameObject.GetComponent(). So it tries to retrieve the component from the game object that the caller itself is a component on. If it's not there you get null.

    Building the future of holographic navigation. We're hiring.

  • Options

    @stepan_stulov

    Many thanks for your correct answer!

    I was not aware that GazeStabilizer was actually a script.

    I thought it was just an AR-specific component, distributed with the learning materials for that particular MS Academy lesson in the imported bundle.

    I added the script as a component to my GazeManager and that resolved the errors.

    Cheers,

Sign In or Register to comment.