Exemplo n.º 1
0
    public override void OnCloudAnchorLocated(AnchorLocatedEventArgs args)
    {
        CloudSpatialAnchor cloudAnchor = args.Anchor;

        // callback is sometimes called multiple times for the same anchor, so we ensure only one object is instantiated per anchor ID
        if (!instantiatedAnchorIds.Contains(args.Identifier))
        {
            // load recording
            string        recordingId     = anchorStore.GetRecordingId(args.Identifier);
            HoloRecording loadedRecording = LoadHoloRecording(recordingId);

            // Instantiate anchored object - will be the parent object of hands recording and representation
            GameObject  anchoredObject = new GameObject();
            WorldAnchor wa             = anchoredObject.AddComponent <WorldAnchor>();
            wa.SetNativeSpatialAnchorPtr(cloudAnchor.LocalAnchor);

            // instantiate representation and pass the recording to it
            Vector3 newRepLocation = new Vector3(loadedRecording.positionXRep, loadedRecording.positionYRep, loadedRecording.positionZRep);
            InstantiateRecordingRepresentation(ref anchoredObject, atLocation: newRepLocation, atPalm: false);

            HoloPlayerBehaviour playerComponent = recordingRepresentationInstance.GetComponent <HoloPlayerBehaviour>();
            playerComponent.PutHoloRecordingIntoPlayer(recordingId, loadedRecording, anchoredObject, anchorStore, openKeyboard: false);

            // Mark already instantiated Anchor Ids so that nothing is instantiated more than once.
            instantiatedAnchorIds.Add(args.Identifier);
        }
    }