示例#1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="value"></param>
 public void SetHitTestMode(HitTestMode value)
 {
     if (this.hitTestMode != value)
     {
         this.hitTestMode = value;
         BoxCollider collider = this.gameObject.GetComponent <BoxCollider>();
         if (this.hitTestMode == HitTestMode.Raycast)
         {
             if (collider == null)
             {
                 collider = this.gameObject.AddComponent <BoxCollider>();
             }
             this.container.hitArea = new BoxColliderHitTest(collider);
             if (_ui != null)
             {
                 UpdateHitArea();
             }
         }
         else
         {
             this.container.hitArea = null;
             if (collider != null)
             {
                 Component.Destroy(collider);
             }
         }
     }
 }
示例#2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="value"></param>
 public void SetHitTestMode(HitTestMode value)
 {
     if (this.hitTestMode != value)
     {
         this.hitTestMode = value;
         BoxCollider collider = this.gameObject.GetComponent<BoxCollider>();
         if (this.hitTestMode == HitTestMode.Raycast)
         {
             if (collider == null)
                 collider = this.gameObject.AddComponent<BoxCollider>();
             this.container.hitArea = new BoxColliderHitTest(collider);
             if (_ui != null)
                 UpdateHitArea();
         }
         else
         {
             this.container.hitArea = null;
             if (collider != null)
                 Component.Destroy(collider);
         }
     }
 }
示例#3
0
		/// Return information about the area under the specified point
		public HitInfo HitTest(Point pt, HitTestMode mode)
		{
			if ( points == null )
				Init();

			// shift to spiro coords
			Point translatedPoint=pt;
			translatedPoint.Offset(-location.X, -location.Y);

			// calc distance from center
			double distance = LineUtil.Distance(new Point(0, 0), translatedPoint);

			if ( mode == HitTestMode.Default )
			{
				if (distance > MaxExtent + 5)
					// we're outside the area covered by the spiro
					return HitInfo.None;

				// is it near the line of the fixed circle
				if ( distance > R - 5 && distance < R + 5 )
					// yes
					return HitInfo.FixedCircle;

				// when testing in this mode, we only want to know about a couple
				// of key areas
				if (PointNearSegment(translatedPoint))
					// point is on or near the curve
					return HitInfo.Curve;

				// not interested, in this mode
				return HitInfo.None;
			}

			if ( ResizeHandleRect.Contains(pt) )
				return HitInfo.Resize;

			if ( !FocusRect.Contains(pt) )
				// point is outside focus rect
				return HitInfo.None;

			// determine if the point is on or near the pen
			RectangleF rc = new RectangleF(points[counter], new Size(0, 0));
			rc.Inflate(5, 5);
			if (rc.Contains(translatedPoint))
				return HitInfo.Pen;

			// is it near the line of the moving circle
			double distToMoving = LineUtil.Distance(CurrentMovingCircleCenter, translatedPoint);
			if ( distToMoving < r + 5 && distToMoving > r - 5 )
				// yes
				return HitInfo.MovingCircle;

			// is it near the line of the fixed circle
			if ( distance > R - 5 && distance < R + 5 )
				// yes
				return HitInfo.FixedCircle;

			// nowhere in particular but is within bounds
			return HitInfo.Bounds;
		}