Пример #1
0
    private AnchorHandler LoadAnchor(string id)
    {
        if (anchorStore == null)
        {
            Debug.Log("Anchor store hasn't been loaded.");
            return(null);
        }

        GameObject    anchorGameObject = Instantiate <GameObject>(anchorGameObjectPrefab);
        AnchorHandler anchorHandler    = anchorGameObject.GetComponent <AnchorHandler>();
        GraphNode     node;
        string        anchorName = "";

        if (graphInfo.Nodes.TryGetValue(id, out node))
        {
            anchorName = node.AnchorName;
        }
        else
        {
            Debug.LogWarning($"Unable to find id: {id} in local database.");
        }

        anchorHandler.Initialize(id, anchorName);
        anchorStore.Load(id, anchorHandler.AnchorGameObject);

        return(anchorHandler);
    }
Пример #2
0
    private WorldAnchor CreateAnchor()
    {
        if (anchorStore == null)
        {
            Debug.Log("Anchor store hasn't been loaded.");
            return(null);
        }

        if (updateNeighbourTask != null && !updateNeighbourTask.IsCompleted)
        {
            Debug.Log("Anchor creation task is not finished.");
            return(null);
        }

        string     id               = Guid.NewGuid().ToString();
        Vector3    position         = cameraTransform.TransformPoint(1.1f * Vector3.forward);
        GameObject anchorGameObject = Instantiate(anchorGameObjectPrefab, position, cameraTransform.rotation);

        anchorGameObject.transform.up = Vector3.up;
        AnchorHandler anchorHandler = anchorGameObject.GetComponent <AnchorHandler>();

        anchorHandler.Initialize(id, "");
        WorldAnchor anchor = anchorHandler.Anchor;

        anchorStore.Save(id, anchor);
        existingAnchors.Add(id, anchorHandler);

        Debug.Log($"Anchor {id} is created. Anchor count: {anchorStore.anchorCount}.");

        UpdateGraphInfoOnCreation(id);

        return(anchor);
    }