Set Corners from Rectangle

Hi all, I’m having a heck of a time figuring this out. Does anyone know how to set the corners of a scaled RectTransform from a screen space rectangle? I can’t get it to work for RectTransforms with a scale other than 1.

Do you mean setting the anchors to match a rect like [100, 100, 150, 150] for instance? If so, you can just calculate the anchor position like so:

float xMinRel = rect.xMin / Camera.main.pixelRect.width;
float yMinRel = rect.yMin / Camera.main.pixelRect.height
//etc.

EDIT: Found the answer guys, I put this same post in the the Unity Paid Work forum (complete with screenshots and source code) and offered up $20 to someone to fix it. That worked slick! I had like 4 replies, but only one of them was right. I figured the answer would be easy to SOMEone out there, and I was right.

I’m going to have to do this a lot more often! I sweated for DAYS before resorting to this. It’s hard to get help here in the Unity forums, but when I need it, I’m willing to pay for it.