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.

Is there a bug with setting a WorldAnchor tag property?

I have been puzzling about this for months thinking why I have had a problem not reported by other people and I have come to the conclusion that there is perhaps a bug elsewhere and not in my own software. Please correct me if other developers have has a different experience than this. This is situation.

I like to apply some extra data to every WorldAnchor gameobject I save by means of for example:-

        var m = GameObject.CreatePrimitive(PrimitiveType.Sphere);
        im.transform.position = pos;
        var anchor = m.GetComponent<WorldAnchor>() as WorldAnchor;
         anchor.transform.localScale = m.transform.localScale;
         if (anchor != null)
                //so far so good - no problems but the next step is the problem:-
               anchor.tag="anything you like"; //difficult to try and catch this one
//my code doesn't appear to get this far but jumps out of the stack a little and just keeps on running

The anchor.tag property has a get/set pair so you should be able to set it. I have tried setting it in a try/catch loop and reporting the exception without any success.

Can I ask anyone if they have had the same problem as me?

Have I missed something here?


Best Answer


  • Quick question: if you have a transform object from the anchor object doesn't that imply the anchor isn't null? Or did you do this because you've found that the anchor object is volatile and could be set to null at any point thus your logic check for null after the anchor.transform.localScale property?

    If so try putting a lock around the logic that needs setting or updating any property which is attached to the anchor object to see if this helps. From the above description it appears you don't have thread safe code there.

    For Tracing and Debugging try writing out the current thread ID and other environment values, to see if you see any unexpected behavior such as multiple threads accessing your logic..

    Dwight Goins
    CAO & Founder| Independent Architect | Trainer and Consultant | Sr. Enterprise Architect
    MVP | MCT | MCSD | MCPD | SharePoint TS | MS Virtual TS |Windows 8 App Store Developer | Linux Gentoo Geek | Raspberry Pi Owner | Micro .Net Developer | Kinect For Windows Device Developer

  • Thank you both Dwain and spt. Firstly my coding is not that good at the best of times and the 'Null' test in my clip comes a bit late in the day. That was a later addition as part of my diagnostics - sorry. Also spt was correct, delving through the links on WorldAnchor.tag - you can only change it in the Inspector in the Unity Editor and must be just short phrases too!

    It really is a disadvantage of this system when you can use legitimate code, get no errors on compilation and linking then launch something that causes an untrappable error. The workaround for me was easy (as spt alluded to - don't do it).

Sign In or Register to comment.