Shared MR: Local Anchor Transfers in Unity

%3CLINGO-SUB%20id%3D%22lingo-sub-3299281%22%20slang%3D%22en-US%22%3EShared%20MR%3A%20Local%20Anchor%20Transfers%20in%20Unity%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3299281%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20trying%20to%20set%20up%20a%20common%20experience%20between%20two%20Hololens%202%20devices%20in%20the%20same%20room%2C%20following%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fmixed-reality%2Fout-of-scope%2Flocal-anchor-transfers-in-unity%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fmixed-reality%2Fout-of-scope%2Flocal-anchor-transfers-in-unity%3C%2FA%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20made%20a%20fresh%20Unity%2020.3.26f1%20project%2C%20added%20and%20configured%20MRTK%201.0.2203.0%2C%20made%20a%20GameObject%20with%20a%20WorldAnchorManager%20component%20(not%20yet%20sure%20what%20to%20do%20with%20that)%2C%20and%20then%20another%20GameObject%20with%20this%20script%20attached%20to%20it%3A%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Eusing%20System.Collections%3B%0Ausing%20System.Collections.Generic%3B%0Ausing%20UnityEngine%3B%0Ausing%20UnityEngine.XR.WSA.Sharing%3B%0A%0Apublic%20class%20anchorscript%20%3A%20MonoBehaviour%0A%7B%0A%20%20%20%20public%20GameObject%20rootGameObject%3B%0A%20%20%20%20private%20UnityEngine.XR.WSA.WorldAnchor%20gameRootAnchor%3B%0A%0A%0A%20%20%20%20%2F%2F%20Start%20is%20called%20before%20the%20first%20frame%20update%0A%20%20%20%20void%20Start()%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20gameRootAnchor%20%3D%20rootGameObject.GetComponent%3CUNITYENGINE.XR.WSA.WORLDANCHOR%3E()%3B%0A%0A%20%20%20%20%20%20%20%20if%20(gameRootAnchor%20%3D%3D%20null)%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20gameRootAnchor%20%3D%20rootGameObject.AddComponent%3CUNITYENGINE.XR.WSA.WORLDANCHOR%3E()%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%0A%20%20%20%20%2F%2F%20Update%20is%20called%20once%20per%20frame%0A%20%20%20%20void%20Update()%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%7D%0A%7D%3C%2FUNITYENGINE.XR.WSA.WORLDANCHOR%3E%3C%2FUNITYENGINE.XR.WSA.WORLDANCHOR%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20led%20to%20the%20following%20error%20in%20the%20Unity%20editor%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3EAssets%5Canchorscript.cs(4%2C26)%3A%20error%20CS0234%3A%20The%20type%20or%20namespace%20name%20'Sharing'%20does%20not%20exist%20in%20the%20namespace%20'UnityEngine.XR.WSA'%20(are%20you%20missing%20an%20assembly%20reference%3F)%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'd%20appreciate%20any%20help%20understanding%20why%20this%20happens%20and%20what%20I%20can%20do%20to%20make%20the%20script%20compile.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3299281%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Ehololens%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMRTK%20Unity%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOpenXR%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EUnity%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3514043%22%20slang%3D%22en-US%22%3ERe%3A%20Shared%20MR%3A%20Local%20Anchor%20Transfers%20in%20Unity%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3514043%22%20slang%3D%22en-US%22%3Eworld%20anchors%20are%20no%20longer%20be%20supported%20since%20unity%20version%202020%3C%2FLINGO-BODY%3E
Occasional Visitor

I'm trying to set up a common experience between two Hololens 2 devices in the same room, following https://docs.microsoft.com/en-us/windows/mixed-reality/out-of-scope/local-anchor-transfers-in-unity.

 

I made a fresh Unity 20.3.26f1 project, added and configured MRTK 1.0.2203.0, made a GameObject with a WorldAnchorManager component (not yet sure what to do with that), and then another GameObject with this script attached to it: 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.WSA.Sharing;

public class anchorscript : MonoBehaviour
{
    public GameObject rootGameObject;
    private UnityEngine.XR.WSA.WorldAnchor gameRootAnchor;


    // Start is called before the first frame update
    void Start()
    {
        gameRootAnchor = rootGameObject.GetComponent<UnityEngine.XR.WSA.WorldAnchor>();

        if (gameRootAnchor == null)
        {
            gameRootAnchor = rootGameObject.AddComponent<UnityEngine.XR.WSA.WorldAnchor>();
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

 

This led to the following error in the Unity editor:

 

Assets\anchorscript.cs(4,26): error CS0234: The type or namespace name 'Sharing' does not exist in the namespace 'UnityEngine.XR.WSA' (are you missing an assembly reference?)

 

I'd appreciate any help understanding why this happens and what I can do to make the script compile.

1 Reply
world anchors are no longer be supported since unity version 2020