|
| 10 Jun 2014 06:33 PM |
I am trying to make a script that proportionally changes the size of an Image GUI if the User's Screen Resolution is bigger than 1920x1080. This isn't working correctly because for some reason it DOES catch "GUI" to be changed, but the Property that is changed ISN'T AbsoluteSize, even though it actually is.
And when I put the print parts AFTER the "if Property" conditional, it doesn't update whenever I resize the screen.
Is there anything about AbsoluteSize that I am not doing correctly, or is there a workaround to accomplish the same goal?
Current Script: ---------------------------------------------------------
AbsoluteSize = script.Parent.Parent.Parent.AbsoluteSize AbsoluteLength = AbsoluteSize.X AbsoluteHeight = AbsoluteSize.Y GUI = script.Parent GUIOLength = GUI.Size.X.Offset GUIOHeight = GUI.Size.Y.Offset
GUI.Changed:connect(function(Property) wait() if Property == AbsoluteSize then if AbsoluteLength > 1920 and AbsoluteHeight > 1080 then GUIOHeight = AbsoluteHeight GUIOLength = (1920*AbsoluteHeight)/1080 print(GUIOHeight) print(GUIOLength) end print("Height of: " .. AbsoluteHeight) print("Length of: " .. AbsoluteLength) end end)
|
|
|
| Report Abuse |
|
|
samy22
|
  |
| Joined: 28 Sep 2008 |
| Total Posts: 2181 |
|
|
| 10 Jun 2014 06:38 PM |
You could just use Scale you know and that would resize automatically to the changing sizes of screens.
However, if you still want to go through with this;
newX = 1/(ScreenGui.AbsoluteSize.X/Gui.Size.X) newY = 1/(ScreenGui.AbsoluteSize.Y/Gui.Size.Y)
Gui.Size = UDim2.new(newX,0,newY,0) --The offset is now converted to scale.
--This will resize the GUI to be the same size no matter how big the screen. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 10 Jun 2014 06:42 PM |
You realize you could of just done
newX = Gui.Size.X/ScreenGui.AbsoluteSize.X and same with y. |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2014 06:49 PM |
@Sammy
But that stretches the image, the image needs to stay at the 1920x1080 proportion.
@cntkillme
Would that do what I just told Sammy? |
|
|
| Report Abuse |
|
|
powertool
|
  |
| Joined: 01 Feb 2008 |
| Total Posts: 3771 |
|
| |
|
samy22
|
  |
| Joined: 28 Sep 2008 |
| Total Posts: 2181 |
|
|
| 10 Jun 2014 06:51 PM |
oh yeah :L
excuse my math.
@theinn Also, yes it would, i'm not particularly sure what you mean.
Wouldn't you just leave it at that huge offset then? Nothing will change it. |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2014 06:52 PM |
@power It's just solving proportions :P |
|
|
| Report Abuse |
|
|
powertool
|
  |
| Joined: 01 Feb 2008 |
| Total Posts: 3771 |
|
|
| 10 Jun 2014 06:56 PM |
Eh, fancy for most people.
Also, I don't know many people with 1080p monitors, and I don't know many with monitors larger than 1080p. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 10 Jun 2014 06:58 PM |
Hint hint
(absY / absX) * X = Y |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2014 06:58 PM |
Right now the size of the gui is 1920x1080
for smaller screens, it is kinda cut off but not dramatically
But for screens larger than 1920x1080, I want to make the image gui bigger but still have that 16:9, or 1080p as they call it, scale. |
|
|
| Report Abuse |
|
|
powertool
|
  |
| Joined: 01 Feb 2008 |
| Total Posts: 3771 |
|
| |
|
samy22
|
  |
| Joined: 28 Sep 2008 |
| Total Posts: 2181 |
|
|
| 10 Jun 2014 07:00 PM |
1080p??? u mean pixels? 1080p being HD.
um, not possible, i think. |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2014 07:01 PM |
1080p ratio
as in 16:9
it needs to be PROPORTIONAL to 1920 x 1080 |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 10 Jun 2014 07:01 PM |
samy, stop replying if you don't know.
Look up what aspect ratios are |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2014 07:04 PM |
@cntkillme
Hmm, could you update the current script to improve it? I'll re-polish it from there
|
|
|
| Report Abuse |
|
|
samy22
|
  |
| Joined: 28 Sep 2008 |
| Total Posts: 2181 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 10 Jun 2014 07:13 PM |
Wow I found an error I never saw until now 'if Property == AbsoluteSize then' AbsoluteSize should be a string.
It should be something like newLength = (16/9) * AbsoluteHeight newHeight = (16/9) * AbsoluteLength
If I'm thinking this correctly. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 10 Jun 2014 07:17 PM |
| Wait I just read your original script, it should work fine... |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2014 07:50 PM |
YES! I fixed it!
GUI = script.Parent GUIOLength = GUI.Size.X.Offset GUIOHeight = GUI.Size.Y.Offset
GUI.Changed:connect(function() wait() AbsoluteSize = script.Parent.Parent.AbsoluteSize AbsoluteLength = AbsoluteSize.X AbsoluteHeight = AbsoluteSize.Y if AbsoluteLength > 1920 and AbsoluteHeight > 1080 then GUIOHeight = AbsoluteHeight GUIOLength = (1920*AbsoluteHeight)/1080 print(GUIOHeight) print(GUIOLength) end print("Height of: " .. AbsoluteHeight) print("Length of: " .. AbsoluteLength) end) |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2014 07:51 PM |
| And now to test it with a person who has a screen bigger than 1920x1080p |
|
|
| Report Abuse |
|
|