BobCowManJoin Date: 2010-05-14 Post Count: 22634 |
How do you get the GUI positions to move positions based on their centers rather than the left edge?
I'm constantly having to adjust a GUI just to get it in the middle of the screen -.- If someone has a better way please elaborate
3:8 BCM / Speedyseat(co-owner) |
|
|
local size = yourGui.Size
local center = UDim2.new((0.5 - (size.X.Scale / 2)), -(size.X.Offset / 2), (0.5 - (size.Y.Scale / 2)), -(size.Y.Offset / 2))
yourGui.Position = center |
|
SunTzu16Join Date: 2012-07-10 Post Count: 999 |
If you're in studio, you just use a calculator or something to divide it in half.
So, if you want to center the GUI, (using the position that scales to the screen), you could just take the size of the GUI, say it's 0.4, or 40% of the screen... (both ways)
Then the position is 0.5 (or centered), you take 0.4 divided by 2 = 0.2
0.5 - 02 = 0.3
You'd position it at 0.3 for both directions. |
|
|
'You'd position it at 0.3 for both directions. '
Only if the x and y are both the same, also you forgot to include what to do for offset
Its -(offset / 2)
The algorithm I posted does it for x scale, x offset, y scale, y offset at the same time. |
|
BobCowManJoin Date: 2010-05-14 Post Count: 22634 |
Thanks for both responses
128, thank you it works like a charm
3:8 BCM / Speedyseat(co-owner) |
|
|
We want a plugin that allows for dragable GUIs meow.
-SonyController, Up-And-Coming ROBLOX/Unity Dev |
|
|
All you would have to do is set the guis draggable property to true and parent it to core gui. |
|
SunTzu16Join Date: 2012-07-10 Post Count: 999 |
I did say both would be 0.4 for size.
I never bother with offset, except for very specific situations, lol
Still, it's the same idea. |
|
|
I see that now, sorry
But its really not the same idea
One is (0.5 - (x / 2))
The other is -(x / 2)
Similar looking I suppose. |
|
SunTzu16Join Date: 2012-07-10 Post Count: 999 |
Yeah, just figured I'd give him another point of view to it to help out.
I don't use offset, so I wouldn't know where to begin with it. lol
Scale works better most of the time. |
|
|
If you use only scale your gui will end up very jacked up on other peoples screens |
|
SunTzu16Join Date: 2012-07-10 Post Count: 999 |
It scales to their screens.
Most stuff I do is like, either really simple like an ammo display for a gun, which would scale with their screen across the top of their toolbar...
Or, it'd be a full screen GUI, and everything is positioned and scaled via percent.
I can't really think of any reason to use offset atm. :/
If you're not careful, people with large screens will have very tiny buttons to click, and vice versa, a small screen would have huge buttons that cover the entire screen.
htt
p://prn
tscr.
com/9tomgr
htt
p://prn
tscr.
com/9tomjl |
|
sayhisam1Join Date: 2009-11-25 Post Count: 2092 |
Offset is incredibly useful in certain cases, especially when using text, since TextScaling is ugly, and having lots of empty space in a box is also ugly. |
|
|
Offset > Scale
With offset, you can guarantee your GUIs look the same on all screens.
Also, some people have terribad aspect ratios.
|
|
SunTzu16Join Date: 2012-07-10 Post Count: 999 |
I've only ever had complaints using offset back years ago when I first started using GUIs, lol...
Most people prefer scaling in my environment, so, I go with scaling...
Offset makes things look, in a relative way, different for every user with a different aspect ratio or screen size. That's the nature of offset. Sometimes this is a good thing, and other times it's a bad thing. I realized how horrible offset can be at times when my little brother opened one of my GUIs and on his 24" screen or so it was horribly tiny, while on my screen it fit perfectly. I had to convert everything to make it stay true to its design among all users.
I think the only issues with scaling will revolve around mobile devices that have a taller layout... but I've never used one, and perhaps it flips from portrait to landscape anyway. ROBLOX isn't very great at scaling in narrow situations, which can be observed in studio.
I had to create a responsive website for my highschool a while back, and many of the same principles apply there as well. An offset of 100 or so pixels looks entirely different for different devices, so we used style sheets that based themselves of the size of the user's screen.
Idk, I mean, it's probably a matter of preference, but you can't tell me that offset will make things look the same for all users... That's both true and false depending on perspective, and that's what most opinions are based on, perspective.
I'll continue using scale until I see a really good reason not to. And when I do, I guess I'll need to stop using GUIs, because there's already plenty of reasons not to use offset. lol |
|
|
it's just a matter of being smart about how you use offset
|
|
AethexJoin Date: 2011-10-16 Post Count: 2193 |
if only roblox supported css for guis :( |
|
|
"if only roblox supported css for guis :("
Someone should remake Anaminus' Gloo GUI Library. You could probably make it similar to CSS and make it fully modernized, with support for aspect ratio preservation and stuff. |
|