当前位置:网站首页>Unity获取canvas 下ui 在屏幕中的实际坐标
Unity获取canvas 下ui 在屏幕中的实际坐标
2022-08-03 19:00:00 【梦回大唐敲代码】
/// <summary>
///获取UI的UI坐标
/// </summary>
/// <param name="targetWordPos"></param>
/// <returns></returns>
public static Vector2 GetUGUIForScreenPos(Vector3 targetWordPos)
{
Vector2 screenPoint = RectTransformUtility.WorldToScreenPoint(Camera.main, targetWordPos);
Vector2 localPoint;
RectTransformUtility.ScreenPointToLocalPointInRectangle(GameObject.Find("Canvas").GetComponent<RectTransform>(), screenPoint, Camera.main, out localPoint);
return localPoint;
}
边栏推荐
猜你喜欢
随机推荐
阿里二面:多线程间的通信方式有几种?举例说明
awk语法-02-运算、数组、格式化输出
PHP base notes - NO. 1
【QT】入门心法
图像超分——Real-ESRGAN快速上手
Word另存为PDF后无导航栏解决办法
2022/08/02------丑数
Confused!Ali was abused on the one hand, but was fortunate to be promoted to Huawei's technology, and successfully got the offer, with an annual salary of 40w
【C语言学习笔记(五)】while循环与for循环
tree命令:以树的形式列出目录中的文件
【C语言学习笔记(七)】C语言重定向输入与输出
2022年7月国产数据库大事记
MySQL详细学习教程(建议收藏)
【Azure 事件中心】使用Azure AD认证方式创建Event Hub Consume Client + 自定义Event Position
When does MySQL use table locks and when to use row locks?You should know this
cocos creater 3.x 插件安装方法
MVC vs MVP
金鱼哥RHCA回忆录:CL210管理计算资源--管理计算节点+章节实验
基于ck+redash构建MySQL慢日志+审计日志展示平台
红日安全内网渗透靶场-VulnStack-1








