已经适配了不同分辨率的缩放问题
下面是 ts 代码
public static F2W(obj: GObject): Vector3 {
let screenPos = obj.LocalToGlobal(Vector2.zero);
screenPos.x = screenPos.x + (obj.actualWidth * GRoot.contentScaleFactor) / 2;
screenPos.y = screenPos.y + (obj.actualHeight * GRoot.contentScaleFactor) / 2;
screenPos.y = Screen.height - screenPos.y;
let worldPos = CameraManager.Instance.MainCamera.ScreenToWorldPoint(new Vector3(screenPos.x, screenPos.y, 0));
return worldPos;
}