当前位置:网站首页>[unity notes] screen coordinates to ugui coordinates
[unity notes] screen coordinates to ugui coordinates
2022-07-07 02:20:00 【Start()】
API :
RectTransformUtility Static functions under class ScreenPointToLocalPointInRectangle
You need to pass in four parameters ,
① RectTransform:
This parameter is equivalent to indicating A canvas , The screen coordinate point is the position of the canvas . Under the canvas UI Coordinate changes are shown in the figure :
② Vector2
Screen coordinates , From bottom left to top right , Use " Input.mousePosition " Can be judged
③ Camera
Canvas The rendering mode is Camera Of , The camera needs to be filled in this parameter ;Overlay Can be filled directly null
④ out Vector2
Output conversion completed UGUI coordinate
The following implementation UI As the mouse moves :
Implementation code :
public RectTransform rect;// Based on which Rect Transform
public RectTransform targetRect;// Following the movement of the mouse UI
void Update()
{
RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, Input.mousePosition, null, out Vector2 v2);
targetRect.localPosition = v2;
}
What we use here is Recttransform.localPosition instead of anchoredPosition,anchoredPosition Is based on the current UI Anchor point to get the coordinate position , If the anchor point is in the center, it is and localPosition equal , Make a note of ~
边栏推荐
- 强化学习如何用于医学影像?埃默里大学最新《强化学习医学影像分析》综述,阐述最新RL医学影像分析概念、应用、挑战与未来方向
- Threadlocalutils (tool class IV)
- 处理streamlit库上传的图片文件
- 2022 system integration project management engineer examination knowledge point: Mobile Internet
- FLIR blackfly s industrial camera: explanation and configuration of color correction and code setting method
- Lumion 11.0软件安装包下载及安装教程
- 激光雷达:Ouster OS产品介绍及使用方法
- String or binary data will be truncated
- Freeswitch dials extension number source code tracking
- 低代码平台中的数据连接方式(上)
猜你喜欢
Blackfly s usb3 industrial camera: buffer processing
argo workflows源码解析
Several classes and functions that must be clarified when using Ceres to slam
#夏日挑战赛#数据库学霸笔记(下)~
FLIR blackfly s industrial camera: synchronous shooting of multiple cameras through external trigger
低代码平台中的数据连接方式(上)
leetcode:5. 最长回文子串【dp + 抓着超时的尾巴】
Word wrap when flex exceeds width
传感器:土壤湿度传感器(XH-M214)介绍及stm32驱动代码
【论文阅读|深读】DNGR:Deep Neural Networks for Learning Graph Representations
随机推荐
Infrared camera: juge infrared mag32 product introduction
Tips for web development: skillfully use ThreadLocal to avoid layer by layer value transmission
FLIR blackfly s usb3 industrial camera: white balance setting method
Recommended collection!! Which is the best flutter status management plug-in? Please look at the ranking list of yard farmers on the island!
The last line of defense of cloud primary mixing department: node waterline design
Tiflash source code reading (IV) design and implementation analysis of tiflash DDL module
Flir Blackfly S工业相机:颜色校正讲解及配置与代码设置方法
张平安:加快云上数字创新,共建产业智慧生态
【论文阅读|深读】 GraphSAGE:Inductive Representation Learning on Large Graphs
sql中批量删除数据---实体中的集合
15million employees are easy to manage, and the cloud native database gaussdb makes HR office more efficient
centos8安裝mysql報錯:The GPG keys listed for the “MySQL 8.0 Community Server“ repository are already ins
Flir Blackfly S 工业相机:配置多个摄像头进行同步拍摄
一片叶子两三万?植物消费爆火背后的“阳谋”
Big guys gather | nextarch foundation cloud development meetup is coming!
[paper reading | deep reading] dngr:deep neural networks for learning graph representations
argo workflows源码解析
Processing image files uploaded by streamlit Library
UC伯克利助理教授Jacob Steinhardt预测AI基准性能:AI在数学等领域的进展比预想要快,但鲁棒性基准性能进展较慢
Jacob Steinhardt, assistant professor of UC Berkeley, predicts AI benchmark performance: AI has made faster progress in fields such as mathematics than expected, but the progress of robustness benchma