Beispiel #1
0
        /// <summary>
        /// Callback to place an object
        /// </summary>
        public void PlaceObject()
        {
            GameObject obj = GameObject.Instantiate(PrefabToPlace);

            if (obj != null)
            {
                obj.transform.position = PlaceObjectStart.transform.position;
                FingersPanRotateScaleComponentScript moveScript = obj.GetComponent <FingersPanRotateScaleComponentScript>();
                if (moveScript != null)
                {
                    moveScript.StateUpdated.AddListener(PlacedObjectGestureCallback);
                }
            }
        }
Beispiel #2
0
 private void LongPressGestureUpdated(DigitalRubyShared.GestureRecognizer r)
 {
     FingersPanRotateScaleComponentScript.StartOrResetGesture(r, BringToFront, Camera, gameObject, spriteRenderer, GestureRecognizerComponentScriptBase.GestureObjectMode.RequireIntersectWithGameObject);
     if (r.State == GestureRecognizerState.Began)
     {
         transform.localScale *= DragScale;
         panZ      = Camera.WorldToScreenPoint(transform.position).z;
         panOffset = transform.position - Camera.ScreenToWorldPoint(new Vector3(r.FocusX, r.FocusY, panZ));
         if (DragStarted != null)
         {
             DragStarted.Invoke(this, System.EventArgs.Empty);
         }
     }
     else if (r.State == GestureRecognizerState.Executing)
     {
         Vector3 gestureScreenPoint = new Vector3(r.FocusX, r.FocusY, panZ);
         Vector3 gestureWorldPoint  = Camera.ScreenToWorldPoint(gestureScreenPoint) + panOffset;
         if (rigidBody != null)
         {
             rigidBody.MovePosition(gestureWorldPoint);
         }
         else if (rigidBody2D != null)
         {
             rigidBody2D.MovePosition(gestureWorldPoint);
         }
         else
         {
             transform.position = gestureWorldPoint;
         }
         if (DragUpdated != null)
         {
             DragUpdated.Invoke(this, System.EventArgs.Empty);
         }
     }
     else if (r.State == GestureRecognizerState.Ended)
     {
         transform.localScale /= DragScale;
         if (spriteRenderer != null && BringToFront)
         {
             spriteRenderer.sortingOrder = startSortOrder;
         }
         if (DragEnded != null)
         {
             DragEnded.Invoke(this, System.EventArgs.Empty);
         }
     }
 }