Setting RectTransform according to "Scale with screen size" UI scale mode

I have a contextual window that is set to follow the cursor with a certain offset. The problem is that since the offset is a fixed length, when the resolution changes, the length seems to become smaller. What is the best option to make the length adapt to the screen resolution ?

You can check the Screen width in the awake and change the offset depending of the screenwidth