【发布时间】:2015-12-18 11:03:16
【问题描述】:
我的画布处于屏幕空间覆盖渲染模式。所以我想要的是当用户触摸屏幕时,某些图像必须完全出现在用户触摸屏幕的相同位置。我的图像应该在 UI 层。如果我的画布处于屏幕空间相机渲染模式,我会通过以下方式实现结果..
Image img = null // I assign it via the inspector
void Update()
{
if(Input.GetMouseButtonDown(0))
{
Vector2 point;
RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)img.rectTransform.parent,
Input.mousePosition, canvasCamera, out point);
img.rectTransform.anchorPosition = point;
}
}
但我想在屏幕空间覆盖渲染模式中实现相同的结果,因为我有很多不适合屏幕的 UI 组件。请帮帮我。
【问题讨论】:
标签: c# user-interface unity3d