Exemplo n.º 1
0
        private void SetImage(ARTrackedImage trackedImage)
        {
            var newPrefab = AnimalsManager.Instance.GetAnimalByName(trackedImage.referenceImage.name).prefab;

            var placedPrefab = Instantiate(newPrefab, trackedImage.transform.position, trackedImage.transform.rotation, trackedImage.transform);

            placedPrefab.AddComponent <ArKitObject>();

            // Init object manipulator ( Tracked Image )
            trackedImage.GetComponent <ArKitManipulatorsManager>().ArKitObject    = placedPrefab.GetComponent <ArKitObject>();
            trackedImage.GetComponent <ArKitManipulatorsManager>().rayCastManager = rayCastManager;
            trackedImage.GetComponent <ArKitManipulatorsManager>().mainCamera     = mainCamera;

            // Instantiate object selected visual queue ( circle under object )
            var selectionVisualization = Instantiate(selectionPrefab, placedPrefab.transform, true);

            selectionVisualization.transform.localPosition = Vector3.zero;
            selectionVisualization.transform.localScale    = placedPrefab.transform.localScale;
            selectionVisualization.transform.localRotation = Quaternion.Euler(0, 0, 0);

            // Init prefab components
            placedPrefab.GetComponent <ArKitObject>().Init(trackedImage.GetComponent <ArKitManipulatorsManager>(), selectionVisualization, runtimeAnimatorController);

            // Set object selected
            manipulationSystem.Select(placedPrefab.GetComponent <ArKitObject>());

            // Add to list
            placedObjects.Add(trackedImage.gameObject);
        }
Exemplo n.º 2
0
    void UpdateInfo(ARTrackedImage trackedImage)
    {
        if (trackedImage.referenceImage.name == "Rafflesia")
        {
            trackedImage.GetComponent <itp.Tracked>().Choose(0);
        }
        if (trackedImage.referenceImage.name == "Logo")
        {
            trackedImage.GetComponent <itp.Tracked>().Choose(1);
        }
        if (trackedImage.referenceImage.name == "QRCode")
        {
            trackedImage.GetComponent <itp.Tracked>().Choose(2);
        }

        if (trackedImage.trackingState == TrackingState.Tracking)
        {
            trackedImage.transform.localScale = new Vector3(trackedImage.size.x, trackedImage.size.x, trackedImage.size.y);
            //trackedImage.GetComponent<Renderer>().material.mainTexture = (trackedImage.referenceImage.texture == null) ? null : trackedImage.referenceImage.texture;
        }
        else
        {
            trackedImage.GetComponent <itp.Tracked>().Choose(-1);
        }
    }
Exemplo n.º 3
0
    void UpdateInfo(ARTrackedImage trackedImage)
    {
        // var planeParentGo = trackedImage.transform.GetChild(0).gameObject;
        // var planeGo = planeParentGo.transform.GetChild(0).gameObject;

        // var canvasGo = trackedImage.transform.GetChild(1).gameObject;
        // var detectinoObjs = canvasGo.transform.GetChild(0).gameObject;
        var clickableUx = trackedImage.GetComponent <ClickableTrackableUX>();

        UpdateTrackedImageInfo(trackedImage, null);

        // Disable the visual plane if it is not being tracked
        if (trackedImage.trackingState == TrackingState.Tracking)
        {
            if (clickableUx.tracking == false && clickableUx.flag == false)
            {
                clickableUx.lastTrackedTime = Time.time;
                clickableUx.flag            = true;
                Debug.Log($"[Tracking] Half Tracked: {trackedImage.referenceImage.name}");
            }
            if (clickableUx.flag && Time.time - clickableUx.lastTrackedTime > 0.5f)
            {
                clickableUx.tracking = true;
                clickableUx.flag     = false;
                Debug.Log($"[Tracking] Fully Tracked: {trackedImage.referenceImage.name}");
                Handheld.Vibrate();
                // lastTrackedTime = -1;
            }

            // if(hideTrackableCoro != null ){
            //  Debug.Log("Stop Hiding Coro");

            //  this.StopCoroutine(hideTrackableCoro);
            //  hideTrackableCoro = null;
            // }
            // // trackedImage.gameObject.GetComponentInChildren<CanvasGroup>().alpha = 1f;
            // trackedImage.gameObject.SetActive(true);
            // // The image extents is only valid when the image is being tracked
            // trackedImage.transform.localScale = new Vector3(trackedImage.size.x, 1f, trackedImage.size.y);
        }
        else if (trackedImage.trackingState == TrackingState.None)
        {
            if (clickableUx.tracking)
            {
                clickableUx.tracking = clickableUx.flag = false;
                Debug.Log($"[Tracking] Lost - None: {trackedImage.referenceImage.name}");
            }

            // Debug.Log($"[Tracking] None: {trackedImage.referenceImage.name}");
            // if(trackedImage.gameObject.activeSelf && hideTrackableCoro == null){
            //  hideTrackableCoro = StartCoroutine( HideImageIfCantTrackInSeconds(0.3f, trackedImage) );
            // }
        }
        else if (trackedImage.trackingState == TrackingState.Limited)
        {
            // StartCoroutine(SetTrackingToFalse_Delayed_Coro(0.3f));
            // tracking = false;
            if (clickableUx.tracking)
            {
                clickableUx.tracking = clickableUx.flag = false;
                Debug.Log($"[Tracking] Lost - Limited: {trackedImage.referenceImage.name}");
            }
            // Debug.Log($"[Tracking] Limited: {trackedImage.referenceImage.name}");
        }

        if (clickableUx.tracking)
        {
            if (hideTrackableCoro != null)
            {
                Debug.Log("Stop Hiding Coro");

                this.StopCoroutine(hideTrackableCoro);
                hideTrackableCoro = null;
            }
            // trackedImage.gameObject.GetComponentInChildren<CanvasGroup>().alpha = 1f;
            trackedImage.gameObject.SetActive(true);
            // The image extents is only valid when the image is being tracked
            trackedImage.transform.localScale = new Vector3(trackedImage.size.x, 1f, trackedImage.size.y);
        }
        else
        {
            if (trackedImage.gameObject.activeSelf && hideTrackableCoro == null)
            {
                hideTrackableCoro = StartCoroutine(HideImageIfCantTrackInSeconds(0.6f, trackedImage));
            }
        }
    }
Exemplo n.º 4
0
 public void Debug_OnImageClicked()
 {
     trackedImageToDebug.GetComponent <ClickableTrackableUX>().OnARImageActivated();
 }