I am new to unity and trying to build a simple game. When I work on unity Editor it seems to work fine.
Say in unity I am checking with dimension 1334x750:
And in phone it looks different - iphone7 - 750*1334
As you see, the text on top basket, the pink ball placement and other balls alignment all are different
I am assuming everything here is under the Canvas GameObject.
In the Canvas Scaler Component of the Canvas select Scale with screen size.
If everything is not under Canvas the issue might be that the barrels are in world space whereas the letters are in Screen Space and hence they vary at different points.
You can use WorldtoScreenPoint() to set the position of the points
Related
I have an issue with different resolutions.
Everything perfectly works on 1920x1080 however when i set it to tablet size like 10x10 aspect ratio 'Player' isn't resizing.
My platforms created under Canvas due to scalement and correct positioning. However my player created outside of the canvas.
Should i create my character under canvas or should i create my platforms outside of it? Currently I am not sure how to solve the issue.
Since player is created outside the canvas, there's no way for canvas to affect it (also player is probably using SpriteRenderer not Image component).
One way would be to put player as Image inside a canvas, but to be honest, canavs is created for UI, not gameplay. Putting all gameplay into UI might (and probably will) create a lot of issues. I'm already surprised that player and platforms interact in your game well as they use different systems.
What you probably want to do is to put all gameplay elements (character, platforms, projectiles, etc.) outside the canvas as sprite renderers and leave canvas for what it's meant to be (UI, maybe backgrounds).
Then, you might come across a problem, where on different resolutions, you have smaller or larger area of gameplay. Your options will be to: live with that, create system that restricts gameplay and fills empty space with background or black bars, or something in between (which is for eg. let vertical gameplay area be different, but horizontal the same).
Here's idea how you could achieve it:
https://forum.unity.com/threads/maintain-the-game-content-area-on-different-types-of-screen-sizes.905384/
How can I get the effect of Screen Space - Overlay Canvas on VR?
I want both of the eye cameras to have menus in the exact same positions.
I don't want to mix it with world space, so the only option I can think of is having a duplicate of each UI element, one for each camera.
Am I missing a simpler solution?
In current Unity,
For use in Unity.UI as conventional UI ..
for any "Sprite (2D and UI)", in fact it always defaults to having "Generate Mip Maps" turned ON. Every time you drop an image in, you have to turn that "off" and apply.
As noted in the comments, these days you can actually use world space UI canvasses, and indeed advanced users may indeed have (say) "buttons that float over the head of Zelda and they are in the far distance". However if you're a everyday Unity user adding a button, just turn it off :)
In Unity, "sprites" can still be positioned in 3D space. For example, on a world space canvas. Furthermore, mipmaps are used when the sprite is scaled. This is because the mipmap sampling is determined by the texel size rather than the distance.
If a sprite is flat and perfectly scaled then there is no reason to use mipmaps. This would likely apply to your icon example.
I suspect that it is enabled by default for 2D games where sprites will often not be perfectly scaled. To clarify, a sprite does not need to be on a canvas. Sprites can exist as their own GameObject with a Sprite Renderer (not on a canvas.) When this is the case, scaling the camera view will change the sprite's size on the screen resulting in mipmapping due to the texel size changing. This results in making the sprite always perfectly scaled challenging without a canvas.
I making a 2d game and I am having some very random problems... My sprites are not displaying as they should be. Below is a screen shot of what I see when I run my game. This bug is present in the game window and the scene window, both when the game is running and not running. And the glitch is not because of the tiles being offset (The background is made up of tiles), if you look closely the player sprite is also glitched up. I have tried restarting unity and my computer, one of which has worked. I have been having this problem ever since i started using tilesets (using one PNG image and cropping out smaller sprites by setting the sprite mode to multiple, instad of using just one PNG image where there is only one sprite and the sprite mode is singular). How do I fix this? (BTW I am using Oryx's lo-fi fantasy and sci-fi sprites at www.oryxdesignlab.com)
This happend when your atlas is not sliced correctly. When you making 2D game there are several important things about sprites.
Set Filter Mode to Point
Set Fromat to 16 bit or TrueColor (in special cases)
Make sure that your atlas is sliced properly.
Edit:
Adjust "Max Size" - make sure is value represents number equal or bigger than spritesheet size
The best way in sliceing atlas in Sprite Editor is NOT to use automatic. I got glithes like that in my project too and those steps can eliminate them.
Have a look at your Sprite in the Sprite Editor. I think you can get to it by double clicking.
Your sprites will have sort of boxes around them to identify each individual sprite (if you set your texture to multiple). One of these boxes will not have sliced correctly, and will have overlapped into another sprite, hence why you're seeing what looks like the arm of another sprite in your picture :)
I am playing with Unity3D and has tried to making a small and simple game. Now wanted to include a splash screen. Since the free version of Unity3D doesn't allow directly choosing the image for splash screen in Player Settings, I have followed this documentation: HOWTO-Splash screen in Unity3D
What I have done is, created a new Scene. Then drag and dropped my PNG image of size 1024x512 px to the Assets. Then clicked on this image and then in the Import Settings pane, I had chosen the Texture Type to Texture and hits Apply button.
Then I had created a new Cube object by going to Game Object --> Create Other --> Cube. Then for this cube, I have the values 0 for the 3 coordinates, and (16,9) for the x,y scaling.
Then dragged and dropped this splash screen image from the Assets window to this Cube. But the rendering gives the image inverted vertically! Also, the image was in White background with some text in it. But in the rendered window(ie. Game), it is in faded color!
Where did I went wrong?
I suspect there are two issues:
I suspect the shader that your cube uses relies on lighting which is why you're getting a faded colour. If that's the case, change the shader on the material to an unlit shader.
The image inverted vertically is a bit odd but I suspect you could scale the cube negatively on whatever axis is incorrect.
I suspect the splash screen may be easier to create with Unity's sprite system.