I am currently working with Unity on a litle platformer for Android. However, I have noticed, that the canvas is just slightly off on my phone than it is in the preview from the unity editor. Here is the difference:
The upper picture is the unity editor, the lower one is from my Samsung S8.
Now, it is clearly not about the black bars. I told the canvas to always render in a 16:9 ratio, so that is fine. However, if you notice the cross, it is just slightly closer to the bottom of the screen. Also to the left of the ground on my phone, you see a little blue line where the background peeks through. Again in the upper picture, this isnt the case. I know it is "just a few pixels" however I am wondering over what I am doing wrong.
I set the canvas to "Scale with screensize" So what could be the issue here?
Thanks for the help!
This is the Dpad: It is an image on the canvas. it works with buttons that are invisible but on top of the dpad.
Samsung S8 native resolution is 2960x1440, so not 16:9? If we control the screen by width, 1440/9*16 = 2560, that would explain the black bar on the side? (2960-2560)/2 each side
Related
I have few scenes in my project. I was able to center all of the other scenes. But i cannot center the main scene in my project. Its fine when it opened on a mobile device(probably because resolution matches i guess). but when i opened it in tablet(its an old tab "xiaomi tab 3") its always align to the right on the screen. I was able to center other scenes but i cant center the main scene to screen for some reason. project setting set as 2D and Expand. I also tried to use Control nod, canves layers, margine containers.. but nothing works. If someone can give any suggestions, Thank you in advance.
img1
https://i.stack.imgur.com/FJOHl.jpg
project
1920 x 1080
I have seen this problem, or similar, in windowed mode. I don't know if this is the exact case, but if it doesn't mess with your project, try full-screen mode.
If it's that, you can also take care of the window bar size (which is a problem because it can change from different devices), since godot will count its pixels too.
Notice that you're only having this problem in one axis.
Also, I think you could take a look into the Viewport Stretch Mode. It could mess your graphics depending of the intended result—but other projects won't even notice, so judge for yourself.
The viewport setting sets the root scene’s Viewport to the base resolution. The rendered output of the root Viewport is then scaled to the display resolution. [...]
The viewport setting is a better choice than the 2d setting when pixel-perfect precision is required, since primary rendering still occurs at the base resolution.
Support multiple devices
Scaling correctly for all devices could be an odyssey, so bon voyage.
I have searched both Stack Overflow, and Unity Answers, but I can't find any information on this problem. I have asked a question on unity answers, still awaiting response.
The problem I have is when I build to either Android, or Web, (haven't tried others), there is a black bar on the right of the screen. On android, it is a duplication, 4 times, of a strip of the screen. about 20px wide, and 1/4 of the screen height, quadrupled up the right side of the screen. When I move objects through the area of the screen being copied, it is animated in the side bar.
on the Web build it is just black, but should be blue background.
My game is 2D, using orthographic camera.
Please help! I have no idea how to even properly search this kind of problem.
I just did a Web player build in a new test project, and it was fine, so it must be some setting in my game project,
Thanks in advance
Edit.
I also did a build in android with a new test project no problems. Then I created a new project, and copied my game assets and other folders into the project directory. Then the silly glitch happened again. I am at a loss here. Any ideas?
Edit * [Solved] Thank you to Josh, the problem was solved!!!! What was going on was on my mainCamera, the Viewport Rect setting were of. I had the settings as
X=0, Y=0, W=0.975, H=1.
So a bit of the width of the screen was being clipped.
I set the settings to the default,
X=0, Y=0, W=1, H=1.
And it worked!!!!
this is a picture of the glitch on my HTC One V Android
This is the glitch on Chrome Web player, no screen copying, just black, where the background should be blue
Have a look at you camera. The first property is 'Clear Flags'. If that is set to 'Don't Clear' whatever was last drawn in any area of the screen will remain in the next frame.
Try setting it to 'Solid Color', or 'Skybox' and set the Skybox Material parameter in Edit -> Render Settings.
Also, check your camera's 'Viewport Rect' and ensure that it's parameters cover your screen. The default values do this; X=0, Y=0, W=1, H=1.
The aspect ratio of your the window your game is being run within will affect the ratio of your camera's bounds. It's not always the same as the editor window within Unity. You can lock the editor window to a specific resolution or aspect ratio by selecting to dropdown box in the top left of you 'Game' tab within Unity.
Beyond this it's hard to tell what's causing the issue without more information. Are you doing something funky with shaders, multiple cameras or rendering paths?
In my Flash AS3 app, I am using
stage.scaleMode = StageScaleMode.SHOW_ALL;
because graphically I want it to be workable out-of-the-box in all kinds of different mobile devices. It works a treat because it does a "best-fit" to the device's screen and simply "adds" black borders around it.
For example, in 4:3 screens it fills the whole screen nicely:
while in 16:9 screens I get black borders on the left and right:
Now here is the problem: when I am moving a display object "off-screen", I don't want it to be rendered inside those black borders.
The question is this: what is the fastest way to "clip" my app - considering I am targeting mobile devices? I have a feeling that a
stage.scrollRect
will blow things up performance-wise...
EDIT : I am using <renderMode>gpu</renderMode>
scrollRect is actually great and even makes your application perform better, unless you're using GPU composition (in which case it really degrades performance). So I'd suggest you trying it first.
But a good alternative solution (as crazy as it sounds) is to just have a huge rectangle with a hole on it on top of everything, as the last children of your stage. So suppose your stage is 640x480. You'd have a black rectangle on top of everything with dimensions of, say, 1640x1480, and with a hole of 640x480 pixels inside of it to let your content be visible. It's a cheap way to mimic a mask without forcing recomposition of the pixels inside that area.
There's problem with HTC Hero and AndEngine's BaseGameActivity: when launched, there's only white screen, without any graphics like background and sprites. But I can see objects like lines (org.anddev.andengine.entity.primitive.Line) etc. and also I can tap on invisible buttons and my code is performing, but it's still white screen.
When I'm launch this app on other devices everything is ok.
Where is the problem?
Seems like my TextureAtlases was too big for this phone and I have to use several smaller atlases.
I have a problem that occurs on some displays (HTC Hero, Motorola Defy, HVGA emulator) where some bitmaps are distorted in a peculiar way: The image apparently is shifted by one or two pixels, e.g. to the left, and the resulting gap on the right side is filled by duplicating pixels from the right border of the bitmap. I use pre-computed LDPI/MDPI/HDPI versions of these bitmaps, e.g. a notification icon that fits the specs for notification icons.
I attached two images that show the effect. Please note: even though it might appear that the bitmap is tiled, this is not the case, other images consistently show that the pixels are not wrapped around but duplicated/stretched.
Has anybody ever had a similar problem?
Thanks in advance for any clues that could help me solve this issue,
Arne