Unity - Trying to fit a game in an android screen - unity3d

I started developing a video game as web, but I want it to run on an android device. It chops off a lot of the game. How can I make the game fit to the screen size of the device?
Thanks!

Are you using Orthographic or Perspective camera? With perspective camera it might be an issue with the aspect ratio so you could just pull the camera back a bit. On orthographic camera you need to calculate the orthographic size for each screen size:
camera.orthographicSize = 640/screenwidth * screenheight/2
Put that in your Start or Awake function and change the normalized width to something that fits your project. More here.

Related

Character is out of Screen in 2D Unity Multiplayer Game

As you know positions are critical in multiplayer game and I want to define same position in different resolutions in my 2d multiplayer game.
My problem is like this: if my resolution is 1080p, it works nicely. However if resolution is set to 800x600, then the other character disappears because of the camera.
How can I make it right?
1080p:
800 x 600:
This is one solution that might work in your case : Controlling Aspect Ratio in Unity
change the z of the camera (Camera.main.transform.position =) by using the screen.width and screen.height and make the screen size inversely proportional to how zoomed in (close to 0 on the z-axis) the camera is

How can I turn off camera video background in Unity ARKit

I'm trying to build a "lights-off" feature in my ARKit app, where I basically turn off the camera video background and only show my 3D content, sort of like VR.
Could someone please help me figure out how to turn off the the video background. I can see that a material called YuVMaterial is being used to render the camera texture but setting that to single color actually covers the entire screen and doesn't show my 3D content either.
You can uncheck the UnityEngine.XR.ARFoundation.ARCameraBackground component under the main AR camera, it will just render a black background.
In Unity, you can switch between cameras while using ARKit. The main camera has a run time spherical video applied to it, so it's not actually your device camera, but a rendering of what the device camera sees. By switching cameras, you can effectively "turn off" the background video image, but still take advantage of the ARKit properties. Have fun.

TVs oversize Apple TV game

We are working on a game using Unity 3D. And now we have a problem with Apple TV build: most of the TV's on which we tested the game use some kind of zoomed screen mode by default. And in our game the edges of the screen are important.
Is there a way to make a TV screen fit the image by default?
You can use Screen.safeArea and position your game edges inside.
And if still necessary build a view where the user can adjust your game edges to his screen edges.

Unity 5 widen view instead of resize

I would like to keep my game the same size on any screen. I don't want it to resize though. I would a player to see more of a game field. All game assets should be fixed size, instead player should see more map. How to do this in Unity 5?
Move the camera backwards, increase the orthographics size of the camera, or increase the FOV, then scale the assets up as a function of distance from the camera.

Device roll compensation on augmented reality

I'm working on an app that performs geolocalization over the camera stream of the iPhone. I use the compass to figure out where to put the icons and information onto the the camera layer. If I rotate the device around yaw axis everything works fine.
However, when I roll the iPhone all the information on screen goes away. That's because when you roll the device the compass orientation also changes. However, there are apps like Layar or Wikitude that allow roll rotation without losing focus on the visual items you have onto the camera layer. That way, these apps allow smooth transition between portrait orientation to landscape orientation.
How they achieve that? How can I compensate the roll rotation of the device to keep information on screen?
By the way, the ARKit framework has the same problem as me.
Thanks.
If you are in 2D maybe it is enough to take the point you are calculating from camera field view and offset heading, calculate the distance to the center of the screen, and use that distance as a radius for a circle to do x += r*cos, y += r*sin with -roll as the angle, so the object moves in a circle against the roll. Then you just have to counter rotate the image itself with a transform (CGAffineTransformMakeRotation) to keep it vertical.