Scaling issue in Unity - c#

I am trying to make a game scene for Unity. However, I can't seem to get rid of this border. Or I can't seem to stretch my background to fit the whole screen. I need this scaling to work for all screen sizes. Here is an image of what is happening.
You can clearly see the blue edging, when I don't want that to be happening. This happens when I test on my Tablet as well. The camera is of size 5, however, when I do some debugging, I notice it gives me positions such as 7.15 when I touch on the screen. How can I scale everything down, I have searched through tons of forums and no one seems to be having this issue.

Are you using UI panel for the background? if so try these step.
1st strech the background Panel to fit the whole canvas size
then change the background panel to stretch in all directions
Then select the canvas object and render mode for screen space camera, assign your camera to it and change the UI scale mode to 'scale with Screen size'

Related

Scaling UI for all resolutions in Unity?

I want to create a 2D game with unity. I use anchor points and canvas scaler as everybody says in the Internet.
The image below shows how do I set anchors
However, when I create an apk for Android. It works for some mobile devices (I tested with Xiaomi, Samsung with 720p,1080p or higher resolutions) but it doesn't work well for tablets. Such as Samsung Galaxy Tab A 10.1. In the image below: left one is Xiaomi, right one is Galaxy Tab
In the internet everyone says it can be done using anchors and canvas scaler and they resize the Game screen and show the UI scales in Unity. Yes, it happens so in unity. But it doesn't happen so in devices. In the image below I wanted to show when I resize the Game screen in unity there is no problem about scaling. What can I do about that? I appreciate for any help in advance.
The thing is, you can expand your UI 100% correctly only by 1 dimension - width or height. Looks like your UI suppose to preserve vertical size and can handle some free space on left and right, so change in Canvas Scaler component "Match" to Height (=1), so it will change your UI only if height is changing.
Change the match value to 0.5 -> 1 what in canvas scaler component and reset or modify UI.

How to anchor one empty game object inside stretchable image in unity

I'm setting up a new app UI (Android), there I need to anchor one empty game object inside a stretchable image. I tried all anchor presets, but when mobile screen resolution is changing my stretchable background image stretching according to the screen size. So I can't able to pin that game object on the specific place in the background image. . That Blue image is a movable image I have to stop that image at that red dot(game object).(1080p resolution)above images.
In Above image, you can see that red image went out of its actual position after changing the screen resolution.(Xperia One resolution (1644 * 3840)).
Because of this, I can't able to stop that movable blue screen at a specific position.
Note: Above all images are sorted by layer by layer with some transparent in the middle of the main image. This is for producing water filling effect in 2D.

Why Does My Unity Game Not Display At Full Size On Some Devices?

Could someone check why my game screen does not maximize on some devices?
Look at the screenshot :
You see the black background and some UI buttons which should be hidden are appearing? The game background is not maximized on some devices.
I am using 1280 x 720 Resolution. I have set a Pivot and Anchor Point In the Rect Transform. But it seems some devices don't display it well.
What should I do to have it maximized on all device? Any ideas?
Thanks
Dennis
I guess you are using UGUI (Unity's built-in GUI system).
Looks like the resulting screen does not match the aspect ratio you used for the UI, so it just rescales evenly until it fits the screen horizontally.
As you can see from the image below, You can have your UI elements scale to fit the screen following different criteria.
Rect Transform Anchors Presets:
If you want your UI to perfectly fit the screen and you don't mind some vertical stretch you might just use the bottom-right option.
However, it's always better to keep in mind the "safe areas" when you design your UI.
It's a concept related to TV screens, but I find it extremely useful for mobile products as well, you can get more info here
You should check if your canvas scaling is maybe set to 0.5 width and 0.5 heigth.
you should change it to 0.0 width and 1.0 heigth.
Also make sure your anchors is right. For the ui part i would write a manager which disables and shows ui based on game states.
hope it helps xD

Specific Draw region within Game Window

Part of the problem I am having with what I am trying to do is trying to explain to others what I want. What I am trying to accomplish is an in-game pop-up menu or window which has its own Draw area. For example lets say I have a pop up window with multiple objects stacked on top of each other, such as button, but there are too many to fit on the window so you need a scroll bar to move them into view. What I want to do is make these object only Draw inside of the window:
http://imgur.com/8IWNEqN
The black area with scribbled pink is the main game window and the centre image is the pop up windows, the dark blue squares being the objects inside. Any code, suggestions, and mainly theory will be appreciated. I've tried drawing them only when they're inside the window and this works but it doesn't look very smooth, I want the object gradually disappearing as they move out the window, not just vanishing when they touch the borders, and especially not slipping out of the window.
Thanks.
Before you do any rendering in XNA you can set the ViewPort on the GraphicsDevice. This lets you restrict where things are being rendered.
For example, if you want to render something to a 100x100 pixel area at the top-left of your screen you might do:
// Create the rectangle
var clipRectangle = new Microsoft.Xna.Framework.Rectangle(0,0,100,100);
// Set the rectangle when you call SpriteBatch.Begin:
mSpriteBatch.Begin(SpriteSortMode.Immediate, renderStates.BlendState,
samplerState,
depthStencilState,
rasterizerState,
null, matrix,
clipRectangle);

Control background not displaying the way I want

Ok so I have a custom control and I am applying a background gradient to it. The control that it is in is set to anchor left and right and the image is set to Stretch on the control.
Here is what the background image looks like when its in the normal size of the form.
Here is what the background image looks like when the control is stretched.
Obviously I want it to look like the top one as far as the edges go. I am using Inkscape to develop the background image. Any help on how to avoid this blurry edge would be much appreciated.
I suggest trying 9 images in your control, one for every edge and one for every corner plus the middle container, maybe you've seen this technique in a lot of websites. If you set all images with good anchor, the top and bottom edges will stretch only sideways and the right and left will stretch upward and downward. The corners would never change and the container would be completly stretchable. I am worried about flickering though since it is in a winform. Worth trying.
If you use a fixed image, even if it is bigger and you shrink it, you'll lose the corners proportions.
When the system resizes the image it is approximating the missing pixels in the new stretched image. There is nothing you can do to prevent the blurring from occurring. The only sensible option I think is adding the image in higher resolution (which should be easy since you use Inkscape to create them) and have the system shrink it instead of stretch it.

Categories

Resources