当前位置: 首页>>代码示例>>C#>>正文


C# RectTransform.InverseTransformPoint方法代码示例

本文整理汇总了C#中UnityEngine.RectTransform.InverseTransformPoint方法的典型用法代码示例。如果您正苦于以下问题:C# RectTransform.InverseTransformPoint方法的具体用法?C# RectTransform.InverseTransformPoint怎么用?C# RectTransform.InverseTransformPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.RectTransform的用法示例。


在下文中一共展示了RectTransform.InverseTransformPoint方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ScreenPointToLocalPointInRectangle

		public static bool ScreenPointToLocalPointInRectangle(RectTransform rect, Vector2 screenPoint, Camera cam, out Vector2 localPoint)
		{
			localPoint = Vector2.zero;
			Vector3 position;
			if (RectTransformUtility.ScreenPointToWorldPointInRectangle(rect, screenPoint, cam, out position))
			{
				localPoint = rect.InverseTransformPoint(position);
				return true;
			}
			return false;
		}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:11,代码来源:RectTransformUtility.cs

示例2: GetCanvasInputPosition

 public static Vector2 GetCanvasInputPosition(RectTransform canvas)
 {
     float camDistance = canvas.gameObject.transform.position.z - Camera.main.transform.position.z;
     if (INPUT_DEBUG) { //return mouse position in canvas
         Vector3 screenPoint = new Vector3(Input.mousePosition.x,Input.mousePosition.y,camDistance);
         Vector3 worldPoint = Camera.main.ScreenToWorldPoint (screenPoint);
         //Debug.Log ("worldpoint: " + worldPoint.x + ", " +worldPoint.y + ", " + worldPoint.z);
         Vector3 canvasPoint = canvas.InverseTransformPoint(worldPoint);
         //Debug.Log ("canvaspoint: " + canvasPoint.x + ", " +canvasPoint.y + ", " + canvasPoint.z);
         return new Vector2(canvasPoint.x,canvasPoint.y);
     } else { //return first finger position in canvas, or 0,0 if no touches exist
         if(Input.touchCount < 1){
             return lastCanvasPos;
         }
         Touch t = Input.GetTouch(0);
         Vector3 screenPoint = new Vector3(t.position.x,t.position.y,camDistance);
         Vector3 worldPoint = Camera.main.ScreenToWorldPoint (screenPoint);
         Vector3 canvasPoint = canvas.InverseTransformPoint(worldPoint);
         lastCanvasPos = new Vector2(canvasPoint.x,canvasPoint.y);
         return lastCanvasPos;
     }
 }
开发者ID:Benedict-SC,项目名称:doom-dial,代码行数:22,代码来源:InputWatcher.cs

示例3: ScreenPointToLocalPointInRectangle

 public static bool ScreenPointToLocalPointInRectangle(RectTransform rect, Vector2 screenPoint, Camera cam, out Vector2 localPoint)
 {
     Vector3 vector;
     localPoint = Vector2.zero;
     if (ScreenPointToWorldPointInRectangle(rect, screenPoint, cam, out vector))
     {
         localPoint = rect.InverseTransformPoint(vector);
         return true;
     }
     return false;
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:11,代码来源:RectTransformUtility.cs

示例4: CalculateDragPosition

		/// <summary>
		/// Calculates the drag position.
		/// </summary>
		/// <returns>The drag position.</returns>
		/// <param name="screenPosition">Screen position.</param>
		/// <param name="canvas">Canvas.</param>
		/// <param name="canvasRect">Canvas rect.</param>
		static public Vector3 CalculateDragPosition(Vector3 screenPosition, Canvas canvas, RectTransform canvasRect)
		{
			Vector3 result;
			var canvasSize = canvasRect.sizeDelta;
			Vector2 min = Vector2.zero;
			Vector2 max = canvasSize;
			
			var isOverlay = canvas.renderMode == RenderMode.ScreenSpaceOverlay;
			var noCamera = canvas.renderMode == RenderMode.ScreenSpaceCamera && canvas.worldCamera == null;
			if (isOverlay || noCamera)
			{
				result = screenPosition;
			}
			else
			{
				var ray = canvas.worldCamera.ScreenPointToRay(screenPosition);
				var plane = new Plane(canvasRect.forward, canvasRect.position);
				
				float distance;
				plane.Raycast(ray, out distance);
				
				result = canvasRect.InverseTransformPoint(ray.origin + (ray.direction * distance));
				
				min = - Vector2.Scale(max, canvasRect.pivot);
				max = canvasSize - min;
			}
			
			result.x = Mathf.Clamp(result.x, min.x, max.y);
			result.y = Mathf.Clamp(result.y, min.x, max.y);
			
			return result;
		}
开发者ID:matmuze,项目名称:cellVIEW_color,代码行数:39,代码来源:Utilites.cs

示例5: GetWorldPointInWidget

 Vector3 GetWorldPointInWidget(RectTransform target, Vector3 worldPoint)
 {
     return target.InverseTransformPoint(worldPoint);
 }
开发者ID:osangar88,项目名称:GameFramework,代码行数:4,代码来源:ScrollRectEnsureVisible.cs

示例6: ScreenPointToLocalPointInRectangle

 public static bool ScreenPointToLocalPointInRectangle(RectTransform rect, Vector2 screenPoint, Camera cam, out Vector2 localPoint)
 {
   localPoint = Vector2.zero;
   Vector3 worldPoint;
   if (!RectTransformUtility.ScreenPointToWorldPointInRectangle(rect, screenPoint, cam, out worldPoint))
     return false;
   localPoint = (Vector2) rect.InverseTransformPoint(worldPoint);
   return true;
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:9,代码来源:RectTransformUtility.cs


注:本文中的UnityEngine.RectTransform.InverseTransformPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。