unity获取ugui上鼠标位置
2017-06-25 10:01
447 查看
unity获取ugui上鼠标位置
新建场景,在场景中拖一个画布(Canvas),然后随便找个地方挂上这个脚本就好了。
RectTransformUtility.ScreenPointToLocalPointInRectangle 从屏幕点到矩形内的本地点
屏幕空间点转换为矩形变换内部的本地位置,该点在它的矩形平面上。
The cam parameter should be the camera associated with the screen point. For a RectTransform in a Canvas set to Screen Space - Overlay mode, the cam parameter should be null.
该cam 参数应该是该相机关联的屏幕点。对于在画布上的矩形变换设置该屏幕空间为-Overlay模式,cam 参数应该为空。
When ScreenPointToLocalPointInRectangle is used from within an event handler that provides a PointerEventData object, the correct camera can be obtained by using PointerEventData.enterEventData (for hover functionality) or PointerEventData.pressEventCamera
(for click functionality). This will automatically use the correct camera (or null) for the given event.
当ScreenPointToLocalPointInRectangle从事件处理器内部提供一个PointerEventData对象被使用时,相机可以通过使用PointerEventData.enterEventData(为悬停功能)或者 PointerEventData.pressEventCamera(为单击功能)被获取。该函数将会自动对指定事件使用正确的相机(或者空)。
RectTransform矩形变换
RectTransform.anchoredPosition 锚点位置
The position of the pivot of this RectTransform relative to the anchor reference point.
该矩形变换相对于锚点参考点的中心点位置。
The anchor reference point is where the anchors are. If the anchors are not together, the four anchor positions are interpolated according to the pivot placement.
锚点参考点是锚点的位置。如果锚点不在一起,四个锚点的位置是根据布置的中心点的位置插值替换的。
Parameters 参数
rect | The RectTransform to find a point inside. |
cam | The camera associated with the screen space position. |
screenPoint | Screen space position. |
localPoint | Point in local space of the rect transform. |
Returns
bool Returns true if the plane of the RectTransform is hit, regardless of whether the point is inside the rectangle.Description 描述
Transform a screen space point to a position in the local space of a RectTransform that is on the plane of its rectangle.屏幕空间点转换为矩形变换内部的本地位置,该点在它的矩形平面上。
The cam parameter should be the camera associated with the screen point. For a RectTransform in a Canvas set to Screen Space - Overlay mode, the cam parameter should be null.
该cam 参数应该是该相机关联的屏幕点。对于在画布上的矩形变换设置该屏幕空间为-Overlay模式,cam 参数应该为空。
When ScreenPointToLocalPointInRectangle is used from within an event handler that provides a PointerEventData object, the correct camera can be obtained by using PointerEventData.enterEventData (for hover functionality) or PointerEventData.pressEventCamera
(for click functionality). This will automatically use the correct camera (or null) for the given event.
当ScreenPointToLocalPointInRectangle从事件处理器内部提供一个PointerEventData对象被使用时,相机可以通过使用PointerEventData.enterEventData(为悬停功能)或者 PointerEventData.pressEventCamera(为单击功能)被获取。该函数将会自动对指定事件使用正确的相机(或者空)。
RectTransform矩形变换
RectTransform.anchoredPosition 锚点位置
The position of the pivot of this RectTransform relative to the anchor reference point.
该矩形变换相对于锚点参考点的中心点位置。
The anchor reference point is where the anchors are. If the anchors are not together, the four anchor positions are interpolated according to the pivot placement.
锚点参考点是锚点的位置。如果锚点不在一起,四个锚点的位置是根据布置的中心点的位置插值替换的。
相关文章推荐
- Unity中UGUI中获取鼠标点击位置以及UI物体的屏幕坐标
- unity中UGUI图片箭头指向鼠标位置
- Unity中获取鼠标位置,且点击鼠标右键则在点击位置显示物体
- Unity获取鼠标点击位置,物体朝鼠标点击处移动
- 获取鼠标在Camera上的位置__Unity
- JTable中怎样获取鼠标所在位置的行数
- js获取鼠标位置杂谈附多浏览器兼容代码
- WinAPI: GetCursorPos - 获取鼠标指针的当前位置
- 如何获取当前鼠标的位置
- 求助:关于IE之中获取鼠标位置
- js获取鼠标位置杂谈附多浏览器兼容代码
- 获取图片上鼠标的位置
- 获取鼠标位置的三维坐标
- 用 javascript 获取当页面上鼠标(光标)位置
- VB 6获取鼠标当前位置API
- js获取鼠标的位置
- 获取鼠标位置
- 获取鼠标在图片坐标位置的小例子
- 获取鼠标当前位置坐标的方法 - 回复 "ps8.0" 同学
- 获取鼠标的相对位置