What is the viewport, and information about the device

I would like to have information about the device so that we can create UIs/ Change gameplay elements based on the viewport. This allows us to create responsive User Interfaces.

[size=4]What is needed[/size]

  1. Allow us to view the Device information. What is the current Window of our user. What is the Width, What is the Height, did we lost focus on our window ?
  2. What is the resolution of our screen. Why ? I want to give higher quality images if the view port has that graphic capabilities.

[size=4]Why[/size]
I personally am looking into UIs based on a grid. The thing is that I’m currently listing to the AbsoluteSize of the ScreenGui. This isn’t ideal, and I would like to give my playerbase a UI that is looking great on there device.

You can use the ViewSizeX and ViewSizeY properties of PlayerMouse to get the viewport. As for resolution, everything is specified in pixels, so I don’t think you have to worry about that since the engine does it for you.

True for a part. But I wish to know more information regarding the device. Are we on a Mobile device, are we on a tablet or at a PC.

And yes, I can figure this out. But comparing the resolution between Mobile and tablet is become quite hard. (Since they are coming really close in the last tablet / phones) Something like Player.Device would be great !

1 Like

Try looking at UserInputService, I think it already does everything you would need.

They’re adding Camera:GetViewport() soon. Source: http://developer.roblox.com/forum/updates/13626-camera-screentoray-worldtopoint-other-fun-things

Camera:GetViewPort() will probably be the same information as ViewSizeX and ViewSizeY from PlayerMouse, though.

Yeah in most cases perhaps, but as Ben put it: “This is better than trying to use ScreenGui.AbsoluteSize or something like it because the ScreenGui object is not guaranteed to report the 3d rendering size of the camera.” And so it’s more of an official support.