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.

MR Design Labs Disable and Enable BoundingBoxShell

Hey everyone,

I'm using the MR Design Labs in my Unity project and what I want to do is manipulate an object, disable that object, move another object to that location and then to be able to return to manipulating the original object again.

My issue here is with finding the bounding box and disabling it, and then reenabling it. I have a script attached to the second object (which is supposed to appear at the location of the first one):

`
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class disableStuff : MonoBehaviour {

GameObject BoundingBoxShell;

private void Start()
{
    BoundingBoxShell = GameObject.Find("BoundingBoxShell(Clone)");
}

private void OnEnable()
{
        BoundingBoxShell.SetActive(false);
} 
private void OnDisable()
{
        BoundingBoxShell.SetActive(true);
}

}`

And OnEnable() gives me a NullReferenceException. What confuses me is, if I move BoundingBoxShell.SetActive(false); to the Start() function, it works perfectly and doesn't give an exception. Is this something to do with how the Bounding box scripts work together? Any advice/help would be greatly appreciated.

Best Answer

  • RailboyRailboy
    edited July 2017 Answer ✓
    I may be misunderstanding, but I would expect this result regardless of Bounding Box's behavior.

    Monobehavior initialization functions are called in the following order: Awake -> OnEnable -> Start. So your OnEnable function is getting called before Start has had a chance to set BoundingBoxShell, giving you a null exception.

Answers

  • RailboyRailboy
    edited July 2017 Answer ✓
    I may be misunderstanding, but I would expect this result regardless of Bounding Box's behavior.

    Monobehavior initialization functions are called in the following order: Awake -> OnEnable -> Start. So your OnEnable function is getting called before Start has had a chance to set BoundingBoxShell, giving you a null exception.
Sign In or Register to comment.