屏幕坐标转化为UI坐标

private Vector3 GetPosition(Vector3 ScreeenPos, Canvas canvas)
    {
        Vector2 pos;
        RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas.transform as RectTransform,
            ScreeenPos, canvas.worldCamera, out pos);
        return new Vector3(pos.x, pos.y, 0);
    }

你可能感兴趣的:(屏幕坐标转化为UI坐标)