Anchor.Extent missing?

  • Issue category: ARDK Documentation
  • Host machine & OS version: Mac
  • ARDK version: 2.0.0
  • Unity version: 2020.3.34

I’ve been working through the example on Plane Detection in the documentation and noticed that the method Anchor.Extent is now missing.

gameObject.transform.localScale = anchor.Extent;

Has this been deprecated, or replaced with something else? Thanks -

Hello Natalie,

anchor.Extent is used in the ARPlaneManager script on line 186 with a lowercase ‘a’. Hope this helps.

Thanks for your reply, Erik - interesting. Yes, I understand the variable in that case has a lowercase name. I was meaning to say that I couldn’t reference the Anchor class property Extent (though I now realize the class name is IARAnchor!) I tried importing all the using statements from the ARPlaneManager to see if I’d overlooked one, but the script still doesn’t recognize Extent. When I looked into it further, it turns out the reason Extent didn’t exist for me was that anchor was being interpreted as an IARAnchor which doesn’t have Extent instead of an IARPlaneAnchor which does. I’m not sure the script in the docs actually works. It might need more explicit typing to fix this problem.

In any case - thanks for pointing out where to find a working Extent example - I’ll use that as a template to get things up and running. Thanks!

Update - Thanks again, Erik - based on what I learned from the ARPlaneManager, the the fix below makes the script in the docs work:

private void OnAnchorsAdded(AnchorsArgs args)
{
    foreach (var anchor in args.Anchors)
    {
        // if the anchor type isn't a plane, don't instantiate anything
        if (anchor is IARPlaneAnchor planeAnchor)
        {
            // remember this anchor and its game object so we can update its position if we receive an update
            _planeLookup.Add(planeAnchor.Identifier, Instantiate(_prefab));
            var gameObject = _planeLookup[planeAnchor.Identifier];

            // display the plane object in the same position, orientation, and scale as the detected plane
            gameObject.transform.position = planeAnchor.Transform.ToPosition();
            gameObject.transform.rotation = planeAnchor.Transform.ToRotation();
            gameObject.transform.localScale = planeAnchor.Extent;
        }

    }
}

void OnAnchorsUpdated(AnchorsArgs args)
{
    foreach (var arAnchor in args.Anchors)
    {
        if (arAnchor is IARPlaneAnchor planeAnchor)
        {
            GameObject gameObject;
            if (_planeLookup.TryGetValue(planeAnchor.Identifier, out gameObject))
            {
                gameObject.transform.position = planeAnchor.Transform.ToPosition();
                gameObject.transform.rotation = planeAnchor.Transform.ToRotation();
                gameObject.transform.localScale = planeAnchor.Extent;
            }
        }
    }
}
1 Like

Thank you for the detailed response and for submitting your code. I’ve created a request with Engineering to review the documentation and referenced your proposed solution.

1 Like

This topic was automatically closed 2 hours after the last reply. New replies are no longer allowed.