RectTransformUtility.ScreenPointToLocalPointInRectangle鼠标位置转换为UI坐标

首先canvas的设置调为camera模式

RectTransformUtility.ScreenPointToLocalPointInRectangle鼠标位置转换为UI坐标

RectTransformUtility.ScreenPointToLocalPointInRectangle鼠标位置转换为UI坐标

如果是overlay模式

RectTransformUtility.ScreenPointToLocalPointInRectangle鼠标位置转换为UI坐标RectTransformUtility.ScreenPointToLocalPointInRectangle鼠标位置转换为UI坐标

你会发现RectTransformUtility.ScreenPointToLocalPointInRectangle为false,因为这个canvas不在camera的视口范围内,即使手动调整到视口范围内也不好调整位置,所以非必要的情况下,我建议camera模式使用此方法

具体API翻译请参考此链接http://gad.qq.com/article/detail/41551/

 

相关文章:

  • 2021-11-18
  • 2022-12-23
  • 2021-08-09
  • 2021-12-26
  • 2021-05-14
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-09
  • 2021-12-07
  • 2022-12-23
相关资源
相似解决方案