I am very new to unity and I'm making my first game, Snake. However, when I build and run it for android everything is very small and is hard to press. Scaling everything up works however when I press play everything is huge and some are out of the screen. Does anyone know why this is happening?
Thanks
Go to your UI canvas and to the canvas scaler, set it to "scale to screen size" and change the resolution to your prefered resolution.
canvas scaler
Related
I couldn't find an option to send a picture to better explain what's happening. Here's a Unity Link that has the photos to explain the issue.
I've tried Camera.main.orthographicsize = 4.0f, a solid number to stay on but the Orthographic Size of the camera keeps changing it's size after resizing the window when I'm in free aspect Unity editor mode and even when I export the Unity game with 1920x1080(16:9) resolution. I want it to stay the same size when resizing the window so that the game can always fit inside the screen in any resolution when resizing the window. The default blue background of the camera displays when I stretch the window's width far enough which I don't want to happen.
This Youtube video has the results I'm looking for but the code unfortunately is not working on Unity 2019. The code provided from this video does entirely different things for me and doesn't solve my issue.
From what I understood is that the screen has to has a fixed resolution.
This link will demonstrate the solution. https://docs.unity3d.com/Manual/GameView.html
It does that by changing the
Game View Aspect from free to a fixed resolution.
Unless this is not what you are looking for then I sugest another solution:
Make a black background image that fits the screen size.
Then change the scale of the objects in the scene relative to the camera.
This link will make the scaling solution, Make object visual size constant despite the distance
I'm making a 2d game for android where I want to make the background blur when a popup opens.
I have tried so many techniques.
Making two camera. Blurred main camera and changing culling mask of secondary camera to the popup layer.
Using grabpass shader in a material and adding it to the background of popup.
Capturing screenshot, blurring the texture and adding it to background of popup as sprite.
Everything doing exact what I want to do. But either they are eating FPS or taking a huge time at first time.
So is there any way or workaround which will not slow it down or lag?
I want the game to adapt to the screen resolution, but I want the viewport to always stay the same, so the game basically just resizes itself when running on different PCs. How do I do it?
So, for example, screen resolution is 1920x1080 and the viewport is 640x480. How do I stretch those 640x480 onto 1920x1080? Is that even possible?
If this did not make any sense, I'll try to explain another way.
Thanks in advance!
I'm currently creating a 2D Android and iOS game using Unity3D engine. I'm testing the game on a nexus 5, and an iPhone 5s device. Everything until now is working fine and I am pretty happy with the result, but when I test that application on an iPad or a Samsung tablet all the objects in my game scene are not in the correct position anymore. Is this a common problem in Unity3D ?
I know I am missing something but I tried to do some research and what I found is only by changing the orthographic camera scale might fix this problem, but I found it as a big amount of code to write as my game have not only one scene but multiple scenes and every scene have it's own game objects.
Is there any other method to do, a good and simple work around for this problem?
It's all about setting the Anchors right.
If you're using the new UI System, make sure you anchor the objects where you want them to be, that's how you will achieve resolution independence.
For more information about anchoring, see this tutorial
Don't have separate scenes for separate devices. You can use the Screen object to check the height and width of your display. Then you can use this to set the orthographic size of your camera to something that makes everything visible as expected.
Update: I misunderstood your question, you say GameObject, i understand UI.
Please check this. I don't have this issue on my game. But when i try it with mac or windows machines, it is problematic. So maybe this can solve.
Other solution is more common which is you and Agumander say, change orthographic size of Camera.
This Is for UI
You can use Unity UI, and don't need to seperate. There are so many different resolution and density devices, you need to create so many scenes. So it is meanless separating scenes.
Unity UI has pixel based solutions which can be very helpfull for many density and resolution options. Forexample, It has VerticalLayoutGroup and HorizontalLayoutGroup for easy list like element visulation.
Most important thing is: Do you want to change UI for different screen size or resolutions? For example iPad has larger screen so user can be see more content. This change UX. Maybe you need to consider this.
So I'm working on a unity project, in which i use a light spot to light up the area which the hero can see (I can't post 3 links in one question so i'll just write it in the comments)
when i launch the game using the play button above( in the editor) everything works fine, outside of the light point, everything is dark, and the light point lights up what's inside of it. BUT, in the Web, Standalone and Android versions(Haven't tried others) they all have the same problem, there is no darkness and the objects in the light point( the light point is not visible) are fully lit up like in this picture (the same error happens in every one of the platforms, but I'm showing the web version)
this is how it happens in the editor(How it's supposed to happen)
Here's how it looks like in the editor
Thank you for your attention
I realised there was something wrong with the directional light I had. I just tweaked it a little bit and VIOLA! It's solved.
The problem was with the global directional light, not the point, because on the directional light I had the "Enable Shadows" unticked and it was rotated awkwardly, so I set the rotation to 90/90/90 and made the color black, set the intensity and ticked enable shadows and that solved it!
Because orthographic camera don't draw shadows for point and spot lights.