Hello everyone.

We have decided to phase out the Mixed Reality Forums over the next few months in favor of other ways to connect with us.

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.

The plan between now and the beginning of May is to clean up old, unanswered questions that are no longer relevant. The forums will remain open and usable.

On May 1st we will be locking the forums to new posts and replies. They will remain available for another three months for the purposes of searching them, and then they will be closed altogether on August 1st.

So, where does that leave our awesome community to ask questions? Well, there are a few places we want to engage with you. 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. 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 Accepted 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 Accepted 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.