Example #1
0
    void Start()
    {
        anchorManager       = FindObjectOfType <AnchorManager>();
        aRTapHandler        = FindObjectOfType <ARTapHandler>();
        appController       = FindObjectOfType <AppController>();
        anchorLerper        = FindObjectOfType <AnchorLerper>();
        renameAnchorHandler = FindObjectOfType <RenameAnchorHandler>();

        anchorConverter = FindObjectOfType <AnchorConverter>();
    }
Example #2
0
    private void AnchorConverter_AnchorLocated(object sender, AnchorLocatedEventArgs args)
    {
        if (args.Status == LocateAnchorStatus.Located)
        {
            Log.debug($"Anchor Located : {args.Anchor.Identifier}");

            if (args.Identifier == null || args.Anchor == null)
            {
                Log.debug("Anchor or Identifier is null");
                return;
            }

            anchorManager.AddCloudSpatialAnchor(args.Anchor);

            foreach (ARAnchor anchor in aRAnchorManager.trackables)
            {
                if (anchor == null)
                {
                    break;
                }
                if (anchor.transform.position == args.Anchor.GetPose().position)
                {
                    Debug.Log($"Trying to add anchor. {anchor.name}");
                    AnchorProperties anchorProperties = anchor.gameObject.GetComponent <AnchorProperties>();

                    Debug.Log($"AnchorID : {anchorProperties.anchorID}");
                    Debug.Log($"Instantiate Render. {anchor.name}");
                    GetAnchorProperties(args.Anchor, anchorProperties);
                    GameObject anchorRender = Instantiate(arAnchorContainerRender, new Vector3(0f, 0f, 0f), Quaternion.Euler(0f, 0f, 0f));
                    if (anchorProperties.anchorLabel != null && anchorProperties.anchorLabel.Length > 0)
                    {
                        anchorRender.GetComponentInChildren <TMPro.TMP_Text>().text = RenameAnchorHandler.LoopLabel(anchorProperties.anchorLabel);
                    }

                    anchorRender.transform.SetParent(anchor.transform, false);
                    Log.debug($" {anchorProperties.anchorLabel} 's anchorRender scale is :{anchorRender.gameObject.transform.localScale.x}, anchor scale is : {anchor.transform.localScale.x}");
                    FindObjectOfType <AnchorButtonPopulator>().AddAnchorToButtonList(anchorProperties);
                    Log.debug($"Assign Parent for Render. {anchor.name}");
                    break;
                }
            }
            anchorFirstTimeFound = true;
            Log.debug($"Checking first AnchorFirstTimeFound :{anchorFirstTimeFound}");
        }
    }