public virtual Vector2 GetTrueRatio(Transform tran) { Vector4 camCorner = U_Camera.GetCorners_Vector4(cam, camSectionHeight); float xRatio = U_Math.GetRatio(tran.position.x, camCorner.z, camCorner.w); float zRatio = U_Math.GetRatio(tran.position.z, camCorner.y, camCorner.x); return(new Vector2(xRatio, zRatio)); }
public virtual void PostionToMapPosition(Transform tran, RectTransform rectTran) { Vector4 camCorner = U_Camera.GetCorners_Vector4(cam, camSectionHeight); float xRatio = U_Math.GetRatio(tran.position.x, camCorner.z, camCorner.w); float zRatio = U_Math.GetRatio(tran.position.z, camCorner.y, camCorner.x); float x = xRatio * bg_width + bg_left; float y = zRatio * bg_height + bg_bottom; rectTran.anchoredPosition = new Vector2(x, y); }
private void Update() { Vector2 screenPos = U_Camera.WorldToScreen(tarObject); rectTrans.position = screenPos + offset; }