|
| 10 Apr 2016 12:39 PM |
I need to know when a user resizes their screen at any given time. This function works just fine so far:
function ResizeGui(prop) if prop == "AbsoluteSize" then -- resize stuff end end
GameGui.Changed:connect(ResizeGui)
GameGui is a ScreenGui in PlayerGui. It works totally fine when a user "drags" the size of a screen, but when that middle button in the top right is clicked, the change is not registered for some reason! How can I detect this? Thanks. |
|
|
| Report Abuse |
|
|
| |
|
Smeers
|
  |
| Joined: 14 Feb 2013 |
| Total Posts: 797 |
|
|
| 10 Apr 2016 12:58 PM |
Odd, it should work o-o
In fact, I'm over 2000% sure it should, I've done it before for a smart resize method that kept aspect ratio.
Now my brain hurts. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2016 01:01 PM |
@Smeers
Check out the left bar here:
https://www.roblox.com/games/160720254/Testing-Grounds
CODE FROM THE COMMENT EARLIER:
local chatSize = SG:GetCore("ChatWindowSize") local chatPosition = SG:GetCore("ChatWindowPosition") local newPos = chatPosition + UDim2.new(0, 0, chatSize.Y.Scale, chatSize.Y.Offset + 44) local newSize = UDim2.new(chatSize.X.Scale, chatSize.X.Offset, 1 - newPos.Y.Scale, -newPos.Y.Offset - 38) SideBar.Position = newPos SideBar.Size = newSize
Works until you click that blasted button... |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2016 01:03 PM |
| I think the chat window isn't being resized fast enough when the button is clicked. Should I just BindToRenderStep the entire sidebar? |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2016 01:08 PM |
| Or should I calculate it using the same math from the core chat script... |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2016 01:38 PM |
SOLUTION:
local PHONE_SCREEN_WIDTH = 640 local TABLET_SCREEN_WIDTH = 1024
function ResizeGui(prop) local newSize = GameGui.AbsoluteSize local chatBarSize local chatBarPosition -- Phone if newSize.X <= PHONE_SCREEN_WIDTH then chatBarSize = UDim2.new(.5, 0, 0, 40) chatBarPosition = UDim2.new(0, 0, .5, 2) -- Tablet elseif newSize.X <= TABLET_SCREEN_WIDTH then chatBarSize = UDim2.new(.4, 0, 0, 40) chatBarPosition = UDim2.new(0, 0, .3, 2) -- Desktop else chatBarSize = UDim2.new(.3, 0, 0, 40) chatBarPosition = UDim2.new(0, 0, .25, 2) end
local newPos = chatBarPosition + UDim2.new(0, 0, 0, 42) local newSize = UDim2.new(chatBarSize.X.Scale, chatBarSize.X.Offset, 1-newPos.Y.Scale, -newPos.Y.Offset-38) SideBar.Position = newPos SideBar.Size = newSize end
Works like a charm. I'll probably simplify it but this works. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2016 01:44 PM |
Ah-ha! Much cleaner!
local newSize = GameGui.AbsoluteSize -- Phone if newSize.X <= PHONE_SCREEN_WIDTH then SideBar.Position = UDim2.new(0, 0, .5, 44) SideBar.Size = UDim2.new(.5, 0, .5, -82) -- Tablet elseif newSize.X <= TABLET_SCREEN_WIDTH then SideBar.Position = UDim2.new(0, 0, .3, 44) SideBar.Size = UDim2.new(.4, 0, .7, -82) -- Desktop else SideBar.Position = UDim2.new(0, 0, .25, 44) SideBar.Size = UDim2.new(.3, 0, .75, -82) end |
|
|
| Report Abuse |
|
|
UFAIL2
|
  |
| Joined: 14 Aug 2010 |
| Total Posts: 6905 |
|
|
| 10 Apr 2016 01:51 PM |
| Camera.ViewportSize works when you click the button btw. |
|
|
| Report Abuse |
|
|