Discussion in ' Scripting ' started by DuendeMar 4, Search Unity. Log in Create a Unity ID. Unity Forum. Forums Quick Links. Asset Store Spring Sale has begun! Unite Now has started! Come level up your Unity skills and knowledge. Come post your questions! Black bars on screen Discussion in ' Scripting ' started by DuendeMar 4, Joined: Oct 11, Posts: Hi, how can I remove the black bars that appear in some resolutions?
For example, resolution x x x I have searched and try a lot of thing but I did not find a solution to this problem, can someone help me? What is missing me? DuendeMar 4, Joined: Feb 22, Posts: 1, If you tell Unity to display your game at a specific aspect ratio, but your game window is a different aspect ratio, Unity uses letterboxing to prevent your game from looking stretched. If you resize your game window to be the same aspect ratio as the resolution you are trying to display, it should go away.
You can also set the game window to "Free Aspect", in which case it will change the game to match the window instead of the other way around. AntistoneMar 5, Thank you very much for answering. DuendeMar 5, Oh, this is in the builds, not in the editor? Are you running in fullscreen mode? Your monitor may not be capable of displaying the exact resolutions you are asking for.
If they appear even in windowed mode, then I would think either they are actual objects in your game or there's something funky with your camera's settings. Yes, it's in fullscreen. I guess there are only 2 solutions to remove the black bars: prevent the user select resolutions that his monitor can not display, or stretch the camera so that the black bars are not shown, am I correct?
Do you know how to do one of those two things or both? Are you selecting resolutions with Unity's built-in pop-up pre-game dialog, or with your own in-game options screen?
If you are using your own options screen, you can of course filter the resolutions according to any criteria that you can implement in code. I would guess that the highest resolution in Screen.Modern games and applications often need to support a wide variety of different screen resolutions and particularly UI layouts need to be able to adapt to that.
The UI System in Unity includes a variety of tools for this purpose that can be combined in various ways. In this how-to we're going to use a simple case study and look at and compare the different tools in the context of that.
In our case study we have three buttons in the corners of the screen as shown below, and the goal is to adapt this layout to various resolutions.
Supported Aspect Ratios
For this how-to we're going to consider four screen resolutions: Phone HD in portrait x and landscape x and Phone SD in portrait x and landscape x The layout is initially setup in the Phone HD Portrait resolution.
UI elements are by default anchored to the center of the parent rectangle. This means that they keep a constant offset from the center. If the resolution is changed to a landscape aspect ratio with this setup, the buttons may not even be inside the rectangle of the screen anymore. One way to keep the buttons inside the screen is to change the layout such that the locations of the buttons are tied to their respective corners of the screen.
The anchors of the top left button can be set to the upper left corner using the Anchors Preset drop down in the Inspector, or by dragging the triangular anchor handles in the Scene View. It's best to do this while the current screen resolution set in the Game View is the one the layout is initially designed for, where the button placement looks correct. See the UI Basic Layout page for more information on anchors.
Similarly, the anchors for the lower left and lower right buttons can be set to the lower left corner and lower right corner, respectively. Once the buttons have been anchored to their respective corners, they stick to them when changing the resolution to a different aspect ratio. When the screen size is changed to a larger or smaller resolution, the buttons will also remain anchored to their respective corners.
However, since they keep their original size as specified in pixels, they may take up a larger or smaller proportion of the screen. This may or may not be desirable, depending on how you would like your layout to behave on screens of different resolutions. In this how-to, we know that the smaller resolutions of Phone SD Portrait and Landscape don't correspond to screens that are physically smaller, but rather just screens with a lower pixel density. On these lower-density screens the buttons shouldn't appear larger than on the high-density screens - they should instead appear with the same size.
This means that the buttons should become smaller by the same percentage as the screen is smaller.Work With Different Screen Resolutions & Aspect Rations - Unity
In other words, the scale of the buttons should follow the screen size. This is where the Canvas Scaler component can help. It is also added by default when creating a new Canvas through the GameObject menu.
With this scale mode you can specify a resolution to use as reference. If the current screen resolution is smaller or larger than this reference resolution, the scale factor of the Canvas is set accordingly, so all the UI elements are scaled up or down together with the screen resolution.
Now, when setting the screen resolution to the Phone SD portrait resolution of xthe entire layout is scaled down so it appears proportionally the same as in full resolution. Everything is scaled down: The button sizes, their distances to the edges of the screen, the button graphics, and the text elements. This means that the layout will appear the same in the Phone SD portrait resolution as in Phone HD portrait; only with a lower pixel density.
One thing to be aware of: After adding a Canvas Scaler component, it's important to also check how the layout looks at other aspect ratios.Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
For some reason your suggested change could not be submitted. And thank you for taking the time to help us improve the quality of Unity Documentation. The returned resolutions are sorted by width with lower resolutions coming first.
The Screen. Setting QualitySettings.
Normally one is used. Note: The array will always be empty on Android devices since the resolution is variable within reason and so there is no restricted set of resolutions to choose from. See Also: Resolution structure, SetResolution. Is something described here not working as you expect it to?
It might be a Known Issue. Please check with the Issue Tracker at issuetracker. Version: Language English. Scripting API. Suggest a change. Submission failed For some reason your suggested change could not be submitted. Description All full-screen resolutions supported by the monitor Read Only.
I'm using Unity 4. I'm making a game for Android and iOS devices. Since I'm pretty new to unity, I can't seem to find a way to work with different screen resolution. I'm using c for my scripts. I want my game to run full screen. I've tested it on iPad 2 and it runs perfect but for iPhone 4 the sides are clipped and for iPhone 5 they are clipped even more.
What is the solution? Obviously this isn't always desired, so there's a couple of ways around this:. You can simply change the camera's aspect ratio to match the one you've designed your game around. So if for example you've designed your game atyou'd do something like this:.
If you're using an orthographic camera, one important thing to keep in mind is that regardless of what screen resolution is being used, the orthographic camera keeps the height at a set value and only changes the width. For example, with an orthographic camera at a size of 10, the height will be set to 2. With this in mind what you'd need to do is compensate for the widest possible camera within each level for example, have a wider background or dynamically change the Orthographic Size of the camera until its width matches what you've created.
GUI components are easier to implement simply by setting their position to depend on the screen resolution wherever needed. Since you said it looks perfect on the Ipad2, I'm guessing you've designed your game to use a aspect ratio, so the "clipping" you mention is just that your orthographic camera has widened.
The solution is to use one of the two methods I described above. You can see how it will look on each device within the unity editor fairly easily. If you go to the game tab what pops up when you press play in the unity editoryou'll see it has a device name, along with a resolution and aspect ratio. Changing this will let you see what it will look like at different aspect ratios. You may want to try capturing the device resolution by using Camera. ScreenWidth and Camera. Then do some math to calculate the difference from the resolution you have and apply it to the parent object.
You need to change camera viewport according to device's aspect ratio. Suppose you made the game for x The easiest way I've solved this was as pointed out by Steven, force my perspective camera aspect ratio to the one I develop for. Of course this deforms some objects if the aspect ration I developed for is to different from the one of the device. For UI objects, if you are using the build-in, I create the rectangles based on a percent of whatever the screen size is.
I'm using NGUI 2. To adjust a perspective camera to different screen aspect ratios with different behaviour than the Unity default, you need some trigonometry. Ok, this is a big question. Many people have referred to forcing an aspect ratio, which is a good solution to consider. However for many games this is not appropriate. To do this, you must build and test every system in your game for different sized and shaped screens.Thank you for helping us improve the quality of Unity Documentation.
Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. For some reason your suggested change could not be submitted.
And thank you for taking the time to help us improve the quality of Unity Documentation. A width by height resolution will be used. If no matching resolution is supported, the closest one will be used. If preferredRefreshRate is 0 default Unity will switch to the highest refresh rate supported by the monitor.
If preferredRefreshRate is not 0 Unity will use it if the monitor supports it, otherwise will choose the highest supported one. On Windows Store Apps, switching to non-native resolution is only supported starting from Windows 8.
To set a specific full-screen mode on a desktop platform, use the method overload tht accepts the FullScreenMode parameter. A resolution switch does not happen immediately; it will actually happen when the current frame is finished. Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker. Version: Language English. Scripting API. Suggest a change.
Submission failed For some reason your suggested change could not be submitted. See Also: resolutions property. Publication Date: Ciro ContinisioNovember 19, Unity now has a Pixel Perfect solution in the form of a package.
Standard screen resolution for PC/Mac game?
It comes with a simple component to put on the Camera which will do the hard work for you and make sure the art stays crisp and aligned with the grid of real, small pixels on any screen. For these reasons, as you are working on the art, consider using work files that are twice the resolution that you actually need or more, then scale them down before bringing them into Unity, or use import settings to reduce their size as they are imported into the engine.
The Import Settings for any image asset allow you to force the maximum resolution to a power of 2. The Import Settings also allow you to define a Max Size and other compression settings per platform, so, for instance, you can have some assets on a certain resolution on PC and just half of it on mobile devices, where contained disk space is crucial. Tip: Unity offers a way to consolidate several Sprites into one through Sprite Atlases.
In addition to being a way to save texture space, atlases also offer one unified way of controlling the Max Size rather than having to set it individually for every single sprite in your project. People have very diverse devices and screens and will see your game in a variety of resolutions and aspect ratios. For phones, the range is huge. Some old devices can go down to less than pixels vertically, but some modern ones will be up to 4K.
Steam also offers a similar service on this page. With Retina an Apple trademark and other modern high-DPI screens, while the actual hardware resolution is very high e. Note: DPI dots-per-inch or PPI points-per-inch, or pixels-per-inch are different names used interchangeably by different manufacturers, but at the end of the day, they mean the same thing: how many pixels are squeezed in a linear inch on screen.
Designing UI for Multiple Resolutions
Traditionally, screens were 72 DPI. Today high-DPI screens are usually DPI, but you can find phones that boast up to DPI or more since they are packing a lot of pixels on relatively small screens. Some examples here. For these screens, you have two options. One is to aim at offering an experience that uses the 4K resolution in full. The downside is that producing 4K-compatible assets takes a lot of extra work. In this case, make sure to highlight it in your marketing materials!!
Owners of consoles like PS4 Pro and Xbox One X, which are compatible with 4K, will love the fact that your game is using the hardware to its full power. So the bottom line is: you need to choose a maximum resolution you are aiming for based on the current market shares, see aboveand set that as your target for the whole project. Everyone in the team will then be able to make decisions knowing that. As we mentioned before, Unity measures distances and sizes in something that is simply called a unit, not in pixels.
For instance, the average humanoid model between 1. Same goes for 3D lighting, where light parameters are meant to stay true to reality.
The Size parameter in the Inspector of an Orthographic camera. With a size of 5, we have a viewport that measures 10 Unity units on the vertical. On Macs which are generally it will be 16 by 10 so less visibility on the horizontal. On a phone held vertically so it becomesthe same camera will show only an area of 5. For instance, any game that scrolls horizontally will benefit from a slender horizontal aspect ratio because the player can see more of the coming hazards.For a description of the general Player settings, see Player Settings.
Enable the Override for Standalone setting to assign a custom icon for your standalone game. You can upload different sizes of the icon to fit each of the squares provided.
This section allows you to specify how the user can customize the screen. For example, here you can determine whether the user can resize the screen and how many instances can run concurrently. Above the common Splash Screen settings, the Player Settings Settings that let you set various player-specific options for the final game built by Unity. More info See in Glossary settings allow you to specify splash images for standalone platforms.
Note: Enabling this feature may reduce performance, especially for tiled GPUs. For details on setting these options, see Delivering your application to the Mac App Store. The Use Player Log property enables writing a log file with debugging information. This is useful for investigating problems with your game. See the Unity Manual Log Files page for further information about log files.
If enabled, your game only runs when it contains a valid receipt from the Mac App Store. Use this when submitting games to Apple for publishing on the App Store. This prevents people from running the game on a different computer to the one it was purchased on.
Note that this feature does not implement any strong copy protection. In particular, any potential crack against one Unity game would work against any other Unity content. However, since Apple requires plugin validation to initially happen before showing the screen setup dialog, you should still enable this property to avoid Apple rejecting your submission. You can choose your mono API compatibility level for all targets. Sometimes a 3rd-party. NET library uses functionality that is outside of your.
NET compatibility level. In order to understand what is going on in such cases, and how to best fix it, try following these suggestions:.