generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: GUI position

Previous Thread :: Next Thread 
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
11 Oct 2015 05:47 PM
a friend entered my game, and said that the GUIs were disproportianate, and i assumed it was because the different screen resolution.. is there any way to make the GUIs scale to each computer's res?
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
11 Oct 2015 05:49 PM
Look up UDim2 on the wiki.

There are 4 sections.
(x scale, x offset, y scale, y offset)

(1, 0, 1, 0) would be the screen size.
(0, 25, 0, 25) would be 25x25 pixels.

(1, -25, 1, -25) would be the size of the screen minus 25 pixels on both x and y.

-The [Guy]
Report Abuse
Aethex is not online. Aethex
Joined: 16 Oct 2011
Total Posts: 2193
11 Oct 2015 05:51 PM
There are two types of positions you can set with GUIs. The format is {0, 0, 0, 0}. I assume you are using Offset, which is {0, x-offset, 0, y-offset}. Offset scales in pixels which means that it'll be the same size on every screen. This also means that if the screen is a lot smaller, it's possible it will cover the entire thing or not appear right. The first section of numbers (called Scale) allow for sizing and positioning to be relative to screen size. For example, a frame with the size UDim2.new(.5, 0, .5, 0) will always be a fourth of the entire screen (half on x, half on y).
Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
11 Oct 2015 05:52 PM
the size of all my guis are in (0,x,0,x) form.. so i have to change them to (x,0,x,0) ????
Report Abuse
Aethex is not online. Aethex
Joined: 16 Oct 2011
Total Posts: 2193
11 Oct 2015 05:59 PM
Yes, but Scale works from 0 to 1. You have to use a fraction of the total size available. For example, a Frame directly in a ScreenGui would be a fourth of the screen at UDim2.new(0.5, 0, 0.5, 0); however, a Frame inside of the Frame that is a fourth of the screen would become a fourth of that frame if it had the same size.

Example:
------------------------------------------
-----------------
------
------

-----------------



------------------------------------------

It would result in an output like that. The top and bottom lines representing the full screen, the ones in the middle are the first frame, and the smallest ones are the second frame inside of the first.
Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
11 Oct 2015 06:03 PM
but i have a lot of GUIs... is there a direct conversion like dividing all of my offset sizes by 1 to get the scale size?
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
11 Oct 2015 06:04 PM
Using scale will be a proportion of your screen.

If your screen is 1024 pixels wide, and your gui is 25 pixels wide, then your scale would be ~.024 (that is 25/1024). This will keep the ratio of gui to screen size for all screens.

-The [Guy]
Report Abuse
Aethex is not online. Aethex
Joined: 16 Oct 2011
Total Posts: 2193
11 Oct 2015 06:05 PM
If you go into a ScreenGui there is a property called AbsoluteSize. You could technically use that as a whole and divide your normal offset numbers by it.
Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
11 Oct 2015 06:08 PM
but is the absolute size accessible? and so can i get the children of every frame and textbox of the playergui and convert it in a script
Report Abuse
Aethex is not online. Aethex
Joined: 16 Oct 2011
Total Posts: 2193
11 Oct 2015 06:10 PM
game.StarterGui.AbsoluteSize.X
or
game.StarterGui.AbsoluteSize.Y
Report Abuse
Aethex is not online. Aethex
Joined: 16 Oct 2011
Total Posts: 2193
11 Oct 2015 06:10 PM
oops, I meant:

game.StarterGui.ScreenGui.AbsoluteSize.X
or
game.StarterGui.ScreenGui.AbsoluteSize.Y
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
11 Oct 2015 06:30 PM
There's really no need to convert. Either you set it with the Offset, which is an exact size, or you set it with Scale. If you set it with scale, you would only do that if you WANT it to be the same proportion of the screen on all devices. You could also use a mix of the two which is definitely useful in some cases.

AbsoluteSize is a read only value. You really shouldn't need to do live conversions based on someone's screen, because that's what Scale already does for you.

-The [Guy]
Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
11 Oct 2015 06:31 PM
i want to everything but is there anyway how to? i have:

p = game.Players.LocalPlayer.PlayerGui
repeat wait() until p ~= nil
for _, gui in pairs(p) do
if ((gui:IsA("Frame") or (gui:IsA("TextBox") or (gui:IsA("TextButton") or (gui:IsA("TextLabel")) then
gui.Parent.AbsoluteSize.X = -- :( :( :(
end
end
Report Abuse
Aethex is not online. Aethex
Joined: 16 Oct 2011
Total Posts: 2193
11 Oct 2015 06:31 PM
he won't have to do them live if it's through the command bar

he just asked how to convert all of his already in-use offset values to scale

If you divide the offset value by the absolute size value, then you can discover what the scale value would end up as.
Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
11 Oct 2015 06:49 PM
okay i re-did it to this:

p = game.Players.LocalPlayer.PlayerGui
repeat wait() until p ~= nil
for _,gui in pairs(p:GetChildren()) do
if ((gui:IsA("Frame")) or (gui:IsA("TextBox")) or (gui:IsA("TextButton")) or (gui:IsA("TextLabel"))) then
gui.Size.X.Scale = UDim2.new((gui.Size.X.Offset/gui.Parent.AbsoluteSize.X))
end
end
Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
11 Oct 2015 07:09 PM
it says scale cannot be assigned to :(

gui.Size.X.Scale = UDim2.new((gui.Size.X.Offset/gui.Parent.AbsoluteSize.X))

help anyone?
Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
11 Oct 2015 07:24 PM
bump





Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
11 Oct 2015 10:13 PM
?
Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
11 Oct 2015 10:24 PM
so this script seemed to work, the only thing is the scale size of the new GUIs do not directly correlate to the offset size, does anyone know another conversion?

p = game.Players.LocalPlayer
game.Lighting.ScreenGui:Clone().Parent=p.PlayerGui
if (p.PlayerGui.ScreenGui ~= nil) then
for _,gui in pairs(p.PlayerGui.ScreenGui:GetChildren()) do
if ((gui:IsA("Frame")) or (gui:IsA("TextBox")) or (gui:IsA("TextButton")) or (gui:IsA("TextLabel"))) then
gui.Size = UDim2.new((gui.Size.X.Offset/gui.Parent.AbsoluteSize.X),0,(gui.Size.Y.Offset/gui.Parent.AbsoluteSize.Y),0)
end
end
end
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
11 Oct 2015 10:24 PM
Scale is read only like that. You have to set Size as a whole with UDim2. To solve your proportion issue, use the offset instead of the scale for whatever was misshapen.

-The [Guy]
Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
11 Oct 2015 10:28 PM
How would using offset solve the proportion issue if scale is the thing that makes GUIs proportiant on ALL screen resolutions? My GUI sizes are all offset sizes, until a friend went into my game and said the GUI is disproportionate which is why I'm converting the offset size to scale
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
11 Oct 2015 10:30 PM
Okay, the trouble is with different screen resolution ratios, your guis get stretched differently if you are using scale for both x and y. Offset will make it an exact size no matter the screen resolution.

-The [Guy]
Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
11 Oct 2015 10:43 PM
But my GUIs are already made using offset for both X and Y, so are you saying there shouldn't be a problem?
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
11 Oct 2015 10:48 PM
Right. It would just get smaller on high resolution screens and larger on low resolution screens. Don't make it too big or it will fill mobile player's screens

-The [Guy]
Report Abuse
Kasumo is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
11 Oct 2015 11:10 PM
Wait then that doesn't solve the problem, so I do have to convert my offset sizes to scale
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image