I want a GUIText object to hug the topleft corner of my screen, and i want it to always sit up there a certain number of pixels (or maybe a certain real-world distance, in centimetres) from the corner. How do i go about accomplishing this?
Right now the thing is in the centre of the screen, and changing its anchor property does not seem to affect this much. I can adjust the offset numbers to make it get into the right position, but then it’s thrown off whenever i resize the game window, which i am wont to do frequently while testing.
what’s the basic theory here? are there some stock scripts suitable for this kind of thing?
Change the anchor preset (click on the little square at the left of the Rect Transform component) and select top-left.
Set pivot to x = 0, y = 1.
Set pos x and pos y to 0, or any pixel offset you want. This offset might not be exactly in pixels, it depends on the Canvas Scaler configuration. If you chose the canvas to resize and set a reference resolution that’s half the real resolution, pos x and pos y values would mean a pixel offset twice as big.
Note that when you change anchor presets, anchors and pivots unity adjusts the other values of the rect transform to keep the object in the same place (just like when you rearrange gameobjects on the hierarchy and their transform is updated). If you don’t want that behaviour make sure “raw edit” mode is checked (it’s the button at the right, with an “R” in it.