I saw a topic but the solution in there dont help (And it errors also, I fixed it but it still does wrong calculation on ui position)
I have no idea how to make it not go offscreen
I saw a topic but the solution in there dont help (And it errors also, I fixed it but it still does wrong calculation on ui position)
I have no idea how to make it not go offscreen
Make the text the same width as the white section, then use TextScaled? I don’t really know what the specifics are for what the UI has got to do
Whole UI ^
Cutted UI ^
(yes background from terraria)
I recommend doing a UIListLayout partnered with UIPadding, keeps everything easy and organised and the UIPadding will keep the text off the borders
I never talked about text, and I literally have shown what is wrong, and the post says “How to keep UI on screen”
Idk what you talking about
Oh I thought you were talking about the text going into the border, my bad, I understand what you mean now.
I recommend getting the AbsolutePosition and AbsoluteSize of the UI to calculate each corners position, then use the ViewportSize property of the current camera, you can compare to see if going outside the bounds of the screen, if it is, then offset the position away from the side its clipping into.
I have tested and
Screen Size in studio is 725 (if divide by 2 its 362,5)
Absolute position Y of ui when its at bottom but still fully visible is 364.943 (basically 365)
If out of screen its ofc more than 365
so I can basically check the absolute position and check if its more than screen Y size / 2
I think that might work
You should probably account for other screen sizes, instead of set size amounts
Like? What do you mean by that
Instead of saying like
ScreenX = 725
ScreenY = 365
Have it so its set like
ScreenX = CurrentCamera.ViewportSize.X
ScreenY = CurrentCamera.ViewportSize.Y
yes ik, thats what I do, I’m just saying that this was current screen size when I tested
Tested on screen size more, it worked too
But I don’t really have an idea how to make it go up depending on how much it behind screen
You could get the amount that the UI is clipping out of the screen, store it as a variable, then use that as the amount to move the ui by?
I dont really know how?
Since the way I used to detect its offscreen kinda
say it was clipping into the bottom, you could do something like this:
local uiBottom = uiPosition.Y + uiSize.Y
local screenBottom = viewportSize.Y
local difference = uiBottom - screenBottom
It does detects it offscreen good
but if I do
AbsolutePosition.Y - ScreenSize.Y/2
It will be like that
I made the offset like
AbsolutePosition.Y - ScreenSize.Y
But I have no idea why when I move it moves where it should be witohut offset and with (Its surely problem in script but I have no idea where for some reason)
(Yeah I found problem but its in detection for some reason it still works not as intended, oh yeah and I got why I think lol)
That’s a better detection than one I did because its more accurate kinda
But I think I have to create (Use*) invisible frame that will go to required position and check if its offscreen, if so then move the actual visible frame to that position with offset
Because either it will just keep going to position offscreen and then position not offscreen
Actually I dont think that I need invisible frame
So yeah thanks to you!
Its still a bit under screen but that fixable with + 10 or something like that
(Actually its fixable with offset + 40 for me)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.