Example #1
0
 public void OnFingerTap(Lean.LeanFinger finger)
 {
     Debug.Log("DEM TAPS");
     // Does the prefab exist?
     if (Prefab != null)
     {
         // Make sure the finger isn't over any GUI elements
         if (finger.IsOverGui == false)
         {
             /*
              * // Clone the prefab, and place it where the finger was tapped
              * var position = finger.GetWorldPosition(10.0f);
              * var rotation = Quaternion.identity;
              * var clone    = (GameObject)Instantiate(Prefab, position, rotation);
              *
              * // Make sure the prefab gets destroyed after some time
              * Destroy(clone, 2.0f);
              */
         }
         else
         {
             if (finger.WhatTouched() == IgnoredObject)
             {
                 var position = new Vector3(finger.ScreenPosition.x, 0.0f, finger.ScreenPosition.y);
                 var rotation = Quaternion.identity;
                 var clone    = (GameObject)Instantiate(Prefab, position, rotation);
                 Destroy(clone, 2.0f);
             }
         }
     }
 }
Example #2
0
    void LateUpdate()
    {
        //Debug.Log(Fingers.ToString());

        if (target && Fingers != null)
        {
            if (Fingers.WhatTouched() == null)
            {
                //Myzoomslider.value min =.5 max =15
                //Jake Hartman
                xSpeed = (MyZoomSlider.value * -1f) + 28f;
                ySpeed = (MyZoomSlider.value * -1f) + 28f;

                x += Lean.LeanTouch.DragDelta.x * xSpeed * 0.02f;
                y -= Lean.LeanTouch.DragDelta.y * ySpeed * 0.02f;

                y = ClampAngle(y, yMinLimit, yMaxLimit);

                Quaternion rotation = Quaternion.Euler(y, x, 0);

                // This exists here because it used to say "MouseWheel" and I wanted to preserve the structure.
                // JOS: 10/20/2016
                distance = Mathf.Clamp(distance, distanceMin, distanceMax);
                float dst = distance;

                /*
                 * RaycastHit hit;
                 * if (Physics.Linecast(target.position, rotation * new Vector3(0f, 0f, -distance) + target.position, out hit))
                 * {
                 *  dst -= hit.distance;
                 * }
                 */
                Vector3 negDistance = new Vector3(0.0f, 0.0f, -dst);
                Vector3 position    = rotation * negDistance + target.position;

                transform.rotation = rotation;
                transform.position = position;

                //Debug.Log("NO TOUCHY THE THING");
            }
            else // User is moving the slider or clicking on something else
            {
                KeepCameraOnWorld();
            }
        }
        else if (target) // Separate so angle is not updated between CUP transitions
        {
            KeepCameraOnWorld();
        }

        MyZoomSlider.value = distance;
        transform.LookAt(target);
    }