Example #1
0
        private static void ConfigureSelection(ARSelectionInteractable interactable)
        {
            interactable.selectionVisualization = GameObject.CreatePrimitive(PrimitiveType.Cube);

            interactable.selectionVisualization.name = "AR Selection Visualization";

            interactable.selectionVisualization.GetComponent <MeshRenderer>().material =
                Resources.Load("GemPlay/Materials/BoundingBox") as Material;

            var bounds = Core.Helpers.Unity.GameObjects.BoundsOfAllMeshRenderers(interactable.gameObject);

            interactable.selectionVisualization.transform.SetPositionAndRotation(
                position: bounds.center,
                rotation: interactable.gameObject.transform.rotation);

            interactable.selectionVisualization.transform.localScale = bounds.size;

            interactable.selectionVisualization.transform.SetParent(interactable.gameObject.transform);

            interactable.selectionVisualization.SetActive(false);
        }
Example #2
0
    // Start is called before the first frame update
    void Start()
    {
        canvasAnnotations = GetComponentInChildren <CanvasAnnotations>(true);
        aRSelection       = GetComponent <ARSelectionInteractable>();
        aRAnnotation      = GetComponent <ARAnnotationInteractable>();
        aRSelection.onSelectEntered.AddListener((xrc) =>
        {
            Debug.Log("Selected " + name, this);
            foreach (var ann in aRAnnotation.annotations)
            {
                ann.annotationVisualization.SetActive(true);
            }
        });
        aRSelection.onSelectExited.AddListener((xrc) =>
        {
            Debug.Log("UnSelected " + name, this);
            foreach (var ann in aRAnnotation.annotations)
            {
                ann.annotationVisualization.SetActive(false);
            }
        });

        canvasAnnotations.ReCenterBtn.onClick.AddListener(() =>
        {
            TraceObj.SetActive(!TraceObj.activeInHierarchy);
        });
        canvasAnnotations.DublicateBtn.onClick.AddListener(() =>
        {
        });
        canvasAnnotations.DeleteBtn.onClick.AddListener(() =>
        {
            DestroyImmediate(gameObject);
        });
        if (GameController.Instance.SpawnParticlePrefab)
        {
            Destroy(Instantiate(GameController.Instance.SpawnParticlePrefab, transform), 3);
        }
    }