コード例 #1
0
 private void OnMouseDrag()
 {
     if (is_colliding)
     {
         if (save_obj == null)
         {
             save_obj = mapped_obj;
         }
         boundbox = save_obj.gameObject.GetComponentInParent <DimBoxes.BoundBox>();
         if (boundbox != null)
         {
             boundbox.EnableBox();
         }
     }
 }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (dragging)
        {
            //ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            Vector3 rayPoint = ray.GetPoint(distance);
            transform.position = rayPoint;
        }

        // if clicked some object
        if (Physics.Raycast(ray, out hit_info, layer_mask))
        {
            distance = Vector3.Distance(transform.position, Camera.main.transform.position);
            dragging = true;

            if (is_colliding)
            {
                boundbox = save_obj.gameObject.GetComponentInParent <DimBoxes.BoundBox>();
                if (boundbox != null)
                {
                    boundbox.EnableBox();
                }
            }
        }

        // follow the mapped obj (calculate the coordinates here)
        if (mapped_obj != null && !dragging)
        {
            Vector3 n_pos = mapped_obj.transform.position;
            if (n_pos != mapped_pos)
            {
                obj.transform.position = mapped_obj.transform.position + mapping_vec;
            }
            else
            {
                Vector3 n_vec = obj.transform.position - mapped_obj.transform.position;
                if (n_vec != mapping_vec)
                {
                    Debug.Log("come in mapping distance management");
                    // move the object toward the mapping object
                    mapping_vec = n_vec;
                    //obj.transform.position = mapped_obj.transform.position + mapping_vec;
                }
            }
        }
    }
コード例 #3
0
    void OnMouseDown()
    {
        distance = Vector3.Distance(transform.position, Camera.main.transform.position);
        dragging = true;

        if (is_colliding)
        {
            if (save_obj == null)
            {
                save_obj = mapped_obj;
            }
            boundbox = save_obj.gameObject.GetComponentInParent <DimBoxes.BoundBox>();
            if (boundbox != null)
            {
                boundbox.EnableBox();
            }
        }
    }