public void onClickPlaceGameObject()
    {
        var planes    = GameObject.FindGameObjectsWithTag("planeTag");
        var particles = GameObject.FindGameObjectsWithTag("particleTag");

        foreach (var plane in planes)
        {
            Destroy(plane);
        }

        foreach (var particle in particles)
        {
            Destroy(particle);
        }

        ARPointCloudVisualizer = GameObject.Find("AR Root").GetComponent <ARPointCloudVisualizer> ();
        ARPlaneVisualizer      = GameObject.Find("AR Root").GetComponent <ARPlaneVisualizer> ();

        Destroy(ARPointCloudVisualizer);
        Destroy(ARPlaneVisualizer);
        Destroy(GameObject.Find("FocusSquare"));

        PlaceGameObjectBtn.gameObject.SetActive(false);
        playmode.gameObject.SetActive(true);
        GameObject.Find("Canvas").GetComponent <PortionControl>().Small();        // placecar 이후 최소 사이즈로 시작
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (state.CurrentState == State.FIRST_PLANE_DETECTED || state.CurrentState == State.POINT_SELECTED)
        {
            if (ValidMouseDown())
            {
                Vector3 vpPos       = new Vector3(Input.mousePosition.x / Screen.width, Input.mousePosition.y / Screen.height, 0f);
                bool    intersected = IntersectInfinitePlane(vpPos, out selectedPoint);
                if (intersected)
                {
                    state.SetState(State.POINT_SELECTED);
                    onPointSelected.Invoke(selectedPoint);

                    if (disableThisAfterSelect)
                    {
                        enabled = false;
                    }
                    if (disablePointCloudAfterSelect)
                    {
                        ARPointCloudVisualizer pointCloud = GetComponent <ARPointCloudVisualizer>();
                        if (pointCloud != null)
                        {
                            pointCloud.enabled = false;
                        }
                    }
                }
                else
                {
                    Debug.LogWarning("Tap didnt intersected infinite plane.");
                }
            }
        }
    }
Esempio n. 3
0
    public void onClickPlaceGameObject()
    {
        var planes    = GameObject.FindGameObjectsWithTag("planeTag");
        var particles = GameObject.FindGameObjectsWithTag("particleTag");

        foreach (var plane in planes)
        {
            Destroy(plane);
        }

        foreach (var particle in particles)
        {
            Destroy(particle);
        }

        ARPointCloudVisualizer = GameObject.Find("AR Root").GetComponent <ARPointCloudVisualizer> ();
        ARPlaneVisualizer      = GameObject.Find("AR Root").GetComponent <ARPlaneVisualizer> ();

        Destroy(ARPointCloudVisualizer);
        Destroy(ARPlaneVisualizer);
        Destroy(GameObject.Find("FocusSquare"));


        PlaceGameObjectBtn.gameObject.SetActive(false);
        colorsPanel.gameObject.SetActive(true);
        lightsPanel.gameObject.SetActive(true);
    }
    void Start()
    {
        ARPlaneHandler.returnARPlane += PlaceMap;
        ARPlaneHandler.resetARPlane  += ResetPlane;

        _pointScript = _arRoot.GetComponent(typeof(ARPointCloudVisualizer)) as ARPointCloudVisualizer;
        _planeScript = _arRoot.GetComponent(typeof(ARPlaneVisualizer)) as ARPlaneVisualizer;
    }
Esempio n. 5
0
    public virtual void OnFirstPlaneDetected(BoundedPlane plane)
    {
        // DISABLE AR scripts
        selectPointScript.enabled = false;
        ARPointCloudVisualizer pointCloud = selectPointScript.GetComponent <ARPointCloudVisualizer>();

        if (pointCloud != null)
        {
            pointCloud.enabled = false;
        }

        detectedPlane = plane;
        onPlane.Invoke(detectedPlane);
        hasDetectedPlane = true;

#if UNITY_EDITOR
        editorDebugScaleReference.SetActive(true);
        editorDebugScaleReference.transform.position = detectedPlane.center;
#endif

        CheckInstantiation();
    }
Esempio n. 6
0
 // Update is called once per frame
 private void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         var camera = GetCamera();
         Ray ray = camera.ScreenPointToRay(Input.mousePosition);
         int layerMask = 1 << LayerMask.NameToLayer("ARGameObject"); // Planes are in layer ARGameObject
         RaycastHit rayHit;
         if (Physics.Raycast(ray, out rayHit, float.MaxValue, layerMask))
         {
             Transform planeTransform = rayHit.collider.transform.parent;
             onPlaneSelected.Invoke(planeTransform);
             if (disableThisAfterSelect)
             {
                 this.enabled = false;
             }
             if (disablePlanesAfterSelect)
             {
                 // Stop adding/removing/updating planes position
                 ARPlaneVisualizer arPlaneVis = GetComponent<ARPlaneVisualizer>();
                 if (arPlaneVis != null)
                 {
                     arPlaneVis.enabled = false;
                 }
             }
             if (hidePointCloudAfterSelect)
             { 
                 // Hide point cloud
                 ARPointCloudVisualizer arPointCloudVis = GetComponent<ARPointCloudVisualizer>();
                 if (arPointCloudVis != null)
                 {
                     arPointCloudVis.enabled = false;
                 }
             }
         }
     }
 }
 void Start()
 {
     arPoints = arRoot.GetComponent <ARPointCloudVisualizer>();
     arPlanes = arRoot.GetComponent <ARPlaneVisualizer>();
     SetAnchorMode(true);
 }