Handling different aspect ratios in your Unity 2D games [RNDBITS-030]

  Рет қаралды 49,167

Rabidgremlin

Rabidgremlin

Күн бұрын

Пікірлер: 146
@Rabidgremlin
@Rabidgremlin 4 жыл бұрын
Since the Auto Letterbox asset is no longer available on the asset store, I have created a free replacement asset. You can get it from here: github.com/rabidgremlin/LetterBoxer
@MRosen613
@MRosen613 4 жыл бұрын
Thanks, but how do i Install those files into my Unity game?
@Rabidgremlin
@Rabidgremlin 4 жыл бұрын
Download the latest .unitypackage file from github.com/rabidgremlin/LetterBoxer/releases (currently LetterBoxer-1.0.0.unitypackage). Then inside Unity, select Assets > Import Package > Custom Package and then choose the .unitypackage file you downloaded (see docs.unity3d.com/Manual/AssetPackagesImport.html ). Once you have installed the package see the .pdf in the LetterBoxer/Documentation folder in your project for instructions on how to setup the component.
@MRosen613
@MRosen613 4 жыл бұрын
@@Rabidgremlin kk thanks
@ananasior
@ananasior 4 жыл бұрын
Holy shit, i am doing a little project for my school with a shitton of maps, which of course need a perfect fit for the screen. I was so worried about the resolution issue, i hope that with this tool i will be able to fit my app to all students screens without problems.
@revengerwizard
@revengerwizard 4 жыл бұрын
Hi, does this work also with a pixel perfect camera?
@Shack
@Shack 5 жыл бұрын
Really appreciate that you went through the errors and how to fix them!
@ozgurgurbuz
@ozgurgurbuz 2 жыл бұрын
I've had been suffering to apply same game view for every possible screen but I ended up finding this tutorial. It does not exactly cover the whole screen as I wanted, but this could work too. So, highly appreciated it, thank you. 💯
@sumitcutevil9260
@sumitcutevil9260 2 жыл бұрын
did yu find anything that covers the whole screen?
@ozgurgurbuz
@ozgurgurbuz 2 жыл бұрын
@@sumitcutevil9260 Nope
@michajadczak4372
@michajadczak4372 3 жыл бұрын
Thank you so much! I found my answer at 1:04 when you mentioned preserving, so all I had to do was shift "match" to 0 on my Canvas Scaler. I still watched it whole, and found that you proposed an even better solution for my game. That's great
@brandonservice9714
@brandonservice9714 2 жыл бұрын
This works super well and its really easy, surprised how perfect this worked in 2022
@realmorteza802
@realmorteza802 2 жыл бұрын
I really, really, really appreciate it. I tried many ways among them, only this way worked. thank you!
@pyrouan8905
@pyrouan8905 Жыл бұрын
Even so much late, I want to express my gratitude for the ones who created this video and this asset
@Rabidgremlin
@Rabidgremlin Жыл бұрын
No worries!
@VajraG
@VajraG 5 ай бұрын
Thanks sir I was trying to find this for about an hr thankfully I got that after watching almost 27 videos
@khantanvirahmed750
@khantanvirahmed750 5 жыл бұрын
Actually..the asset was updated recently..so it works just fine in unity 2019 without any editing.
@inxendere
@inxendere 3 жыл бұрын
based
@koki10190
@koki10190 Жыл бұрын
Couldn't even find a thing about this when googling and you saved me :P
@ulasonat5042
@ulasonat5042 4 жыл бұрын
I'm so grateful for this man! Thanks a lot, know you're loved! :)
@wescube-ligma
@wescube-ligma Жыл бұрын
OMFG YOU JUST SOLVED MY LIFE WORRIES THANK YOU SO MUCH , I WAS SHORTLY BEFORE SCRAPPING MY ENTIRE PROJECT BCS OF THIS
@dedbrid
@dedbrid 3 жыл бұрын
I really, reallyyyyyy appreciate it! You literally saved my game! Thank you so much! 🙏
@JkNiikko
@JkNiikko 4 жыл бұрын
Thanks a lot. I even considered remaking the entire project. 2021 and this video is still relevant.
@loganh6748
@loganh6748 2 жыл бұрын
i feel that. I almost excluded the samsung galaxy fold Z from my game's compatible devices bc the ridiculous aspect ratio for that phone was breaking my game. Good thing i found this video!
@gael5745
@gael5745 6 жыл бұрын
thank you very much, you saved my life, I was already tired of the interface of my game being dislodged because of the change of aspect ratio
@LoganoutGm
@LoganoutGm 4 жыл бұрын
Thank you very much, I had tried many things and you were special in releasing this script. It sure helps a lot of people, congratulations!
@MrXGames
@MrXGames 5 жыл бұрын
Thanks for the upload, been putting this off on my 9x16 2d game, very helpful for 9x18 deployment. I don't see how this kind of functionality is not baked into Unity and practically every vid about aspect ratios is for UI scaling, not the actual game itself. Still gonna try to scale it up to 9x18 without bars, but, this is a great fall-back.
@ARTHUR14523
@ARTHUR14523 4 жыл бұрын
Did you manage to do it without the black bars?
@MrXGames
@MrXGames 4 жыл бұрын
@@ARTHUR14523 I did not. It got too wonky - preferred the bars. Lesson learned though to design the worldspace for the largest dimensions but have all the action occur in the 9x16 play area.
@loganh6748
@loganh6748 2 жыл бұрын
@@MrXGames cheers to that brother
@peterroth5287
@peterroth5287 Жыл бұрын
@@MrXGames Thanks for relaying your lessons learned
@dogukan660
@dogukan660 4 жыл бұрын
Dude I've been trying to solve this problem for days. Thank you so much I was going crazy.
@Michael-The-Composer
@Michael-The-Composer 6 жыл бұрын
Nice informative vid, very clear and you make it all so easy to understand! Thanks! You earned a new sub! :)
@Quizfox
@Quizfox 6 жыл бұрын
Thanks. I was getting annoyed at the game not scaling with the window and this helps a lot.
@skyblueink
@skyblueink 6 жыл бұрын
Wow, thanks! It works great, and thank you for showing how to fix the warnings and errors.
@bobmcbob4399
@bobmcbob4399 2 жыл бұрын
But you see the problem at 4:13 is that your round mouse controlled target reticle asset now disappears into the letterbox bars instead of being constrained to the new reduced vertical space enforced by the new code. How to fix that one?
@sjoerdev
@sjoerdev 5 жыл бұрын
thank you do much, been struggling with this for a while now
@junaidarshad2k
@junaidarshad2k 6 жыл бұрын
Saved me a lot of hassle! Thanks for this video!
@Anton-tb9je
@Anton-tb9je 5 жыл бұрын
tank you very much this is exactly what i have been looking for over the Last days
@ivanpejovic
@ivanpejovic 4 жыл бұрын
Thanks man, this really helped out a lot
@Rabidgremlin
@Rabidgremlin 4 жыл бұрын
Glad to hear it!
@irontim1976
@irontim1976 4 жыл бұрын
@@Rabidgremlin saved my life buddy appreciate it
@AdrenResi
@AdrenResi 6 жыл бұрын
For a long time, I was struggling to figure out what was going wrong with my project since basically nobody was getting the same problem I was having! For this template to work, the camera must be set to "World Space" instead of "Screen Space - Overlay" or "Screen Space - Camera". Of course, that means you'll have to reposition the screen, but that shouldn't take too long to fix.
@Rabidgremlin
@Rabidgremlin 4 жыл бұрын
Unfortunately, the Auto Letterbox asset is no longer in the store. I'm looking into creating a new one. In the mean time see this gamedesigntheory.blogspot.com/2010/09/controlling-aspect-ratio-in-unity.html for some code you may be able to use.
@Rabidgremlin
@Rabidgremlin 4 жыл бұрын
Unfortunately I do not.
@敲键盘的猫
@敲键盘的猫 4 жыл бұрын
@IDK Can you share the link to me? Thanks a lot!
@cH3rs
@cH3rs 4 жыл бұрын
linked code works like a charm
@gustavosancho5914
@gustavosancho5914 4 жыл бұрын
You can achieve a similar result using the method in the link in combination with the "Aspect Ratio Fitter" component
@sydneyidundun7898
@sydneyidundun7898 4 жыл бұрын
@@gustavosancho5914 could you elaborate on this
@KyoKurosagi
@KyoKurosagi 5 жыл бұрын
Thanks. But i use another method. Much more simple. Just select on "Main Camera". Under Inspector "Camera" section, tick on "Physical Camera". Then change the "Field of View" to focus on your needed view. This will fix the camera view no matter what is your ratio or screen size.
@mehmetrdvanyldrm9268
@mehmetrdvanyldrm9268 4 жыл бұрын
How do you do that in 2D?
@YoutubeChannel-oq6ss
@YoutubeChannel-oq6ss 5 жыл бұрын
What if you do not want the black bars? Like how do mobile games on google play get the game to fit to all mobile screen sizes without having black bars?
@alextashkov2772
@alextashkov2772 4 жыл бұрын
Works perfectly. Thank you!
@Layarion
@Layarion 4 жыл бұрын
Why use this over the Canvas Screen Size option with a 0.50 width and height slider bar thing?
@crackedcrackeroncracktheii4209
@crackedcrackeroncracktheii4209 Жыл бұрын
does this only work with 2D games or does it also add black bars and fix the Resolution not 3D games?
@eduardwilson547
@eduardwilson547 3 жыл бұрын
Thank you so much!
@sids3194
@sids3194 4 жыл бұрын
any workaround? the asset is no longer present in the asset store due to it being deprecated .
@Rabidgremlin
@Rabidgremlin 4 жыл бұрын
Yes the asset is unfortunately no longer in the store :( I'm looking into creating a new one. In the mean time see this gamedesigntheory.blogspot.com/2010/09/controlling-aspect-ratio-in-unity.html for some code you may be able to use.
@leducia
@leducia 6 жыл бұрын
Perfect! Thanks :)
@ARTHUR14523
@ARTHUR14523 4 жыл бұрын
Thanks very much. But is there any solution to strech or minimise the game without the black bars?
@xot9897
@xot9897 4 жыл бұрын
how do you do this in unity 2019
@theMagos
@theMagos 6 жыл бұрын
Works nice, but it doesn't affect the UI (the UI will overlap the letterbox). Can this be achieved?
@gergedang928
@gergedang928 6 жыл бұрын
Set canvas render mode to Screen Space - Camera
@lordciciu
@lordciciu 6 жыл бұрын
Sorry, but when i make an app for android the resolution changes with black borders too, if yes how can i remove them?
@sydneydoc
@sydneydoc 7 жыл бұрын
Any plans for adding UI control?
@joelkanna3563
@joelkanna3563 2 жыл бұрын
Same question.
@dogeamazedo883
@dogeamazedo883 5 жыл бұрын
Clear and very neat
@jahmaijones6331
@jahmaijones6331 6 жыл бұрын
you lifesaver!!!
@DarioCorno
@DarioCorno 5 жыл бұрын
Hi and thanks for your video. I was already using the auto letterbox script, but I keep having a problem. I'm using an ortho camera for my game, and cannot in any way get a background instead of the solid color bars after using the plugin. The dragon sample inside auto letterbox seems to be working (by using a sprite linked to the main camera) but all my interactions are based on an orhto camera. Any help?
@shubhambairagi8698
@shubhambairagi8698 4 жыл бұрын
its no longer available on the asset store.. can you please share it somehow.
@AniViRus
@AniViRus 4 жыл бұрын
check the pinned comment
@entreato
@entreato 6 жыл бұрын
Cool, but... this only affects while running it on Editor. I would like to find a solution for my builds aspect ratios.
@michaeldavis6993
@michaeldavis6993 4 жыл бұрын
Me too I have the same problem it has been a few days and I still can't fix it
@Alexander-dk8tb
@Alexander-dk8tb 4 жыл бұрын
@@michaeldavis6993 Same here just emailed the person who made it, maybe a bug in the new version of unity?
@Alexander-dk8tb
@Alexander-dk8tb 4 жыл бұрын
My issue turned out to be with the UI as the rest of the game scales fine on build. In the canvas object there is a "canvas scaler" component. I changed that to scale with screen size and changed it around till it worked.
@Bess2k2
@Bess2k2 6 жыл бұрын
great vid, TY
@Ascaron50
@Ascaron50 6 жыл бұрын
When I have a canvas it keeps adjusting itself on the Z axis when I change the aspect or resolution, why is that ?
@dusansimic1907
@dusansimic1907 6 жыл бұрын
Great vid thanks a lot !
@gazark3068
@gazark3068 4 жыл бұрын
Thank you!
@Bess2k2
@Bess2k2 5 жыл бұрын
God send
@carlosegat1459
@carlosegat1459 4 жыл бұрын
Can you tweak it so the letter box appears only at the top?
@carlosegat1459
@carlosegat1459 4 жыл бұрын
Cameras > ... > Anchor = Bottom
@구독자500명되면이같은
@구독자500명되면이같은 5 жыл бұрын
is there any way to stretch the screen =[
@vuilachinhS
@vuilachinhS 6 жыл бұрын
Thank you very much!!! But It didn't working in ratio 10*16
@leokamikkaze20
@leokamikkaze20 7 жыл бұрын
is there any tweak or something else to make it work? I started a new project, imported the auto letterbox fresh new, set the desired aspect ratio and yet when I play, theres no letterbox and a deformed rendered image :/
@Rabidgremlin
@Rabidgremlin 7 жыл бұрын
+leonardo ferreira did you make the code changes from the video and are you in a 2D project with an orthographic camera?
@ripscru8032
@ripscru8032 4 жыл бұрын
thanks bro
@bymsec
@bymsec 5 жыл бұрын
thank you so muchhhhh broooooooooooo
@unknownuknown4195
@unknownuknown4195 3 жыл бұрын
Are this not working on 3D Games ?
@Rabidgremlin
@Rabidgremlin 3 жыл бұрын
This is only for orthographic cameras which are mostly used for 2D games.
@hanni02678
@hanni02678 6 жыл бұрын
What are your main camera settings ? My UI scales and leaves the screen on every setting :P other than the original. Great vid tho.
@hanni02678
@hanni02678 6 жыл бұрын
Ooo I have figured it out :D, set your canvas on "scale with screen size", put in your resolution under the "reference resolution", change "screen match mode" to "expand" and the number under it doesn't do sh** :D lol. And it should be done :D.
@V1TOCHIN
@V1TOCHIN 5 жыл бұрын
@@hanni02678 Dude I love you! seriously, Ive been struggling with that for so long. I had mine set to match width or height (0.5 like most tutorials tell you). anyway thanks man
@hanni02678
@hanni02678 5 жыл бұрын
@@V1TOCHIN Glad it helped xD alto tbh I totally forgot about this comment.
@gbezjak
@gbezjak Жыл бұрын
@@hanni02678 THANK YOU SO MUCH! YOU ARE A LIFE SAVER! I've been struggling with the UI scaling for way too much.
@alvaroerroz8365
@alvaroerroz8365 6 жыл бұрын
Thanks, I having a problem and maybe you can help me. My player limits depending on the camera limits, if the aspect ratio has not to be framed it works perfectly. But with this solution, when its being framed the Player limits aren't good. Anyones knows why? Please heeeeeeelp :) private void PlayerLimits() { Camera _gameCamera = Camera.main; _xMinPlayerPos = _gameCamera.ViewportToWorldPoint(new Vector3(0f, 0, 0)).x + _padding; _xMaxPlayerPos = _gameCamera.ViewportToWorldPoint(new Vector3(1f, 0, 0)).x - _padding; } private void Movement() { var _newPosX = Mathf.Clamp(transform.position.x + _deltaX, _xMinPlayerPos, _xMaxPlayerPos); transform.position = new Vector2(_newPosX, transform.position.y); _anim.Move(_deltaX); }
@alvaroerroz8365
@alvaroerroz8365 6 жыл бұрын
No one knows?
@inori5138
@inori5138 5 жыл бұрын
Am I Only Cant Do That ?
@bibbisbibbis
@bibbisbibbis 7 жыл бұрын
Surely Unity has a built in way to do this..?
@Rabidgremlin
@Rabidgremlin 7 жыл бұрын
No it does not. If you are doing 3D then the perspective based camera more or less handles this for you. Not so much for 2D.
@abeloftmusic1948
@abeloftmusic1948 7 жыл бұрын
Hey! Nice video :) I have one major problem tho. I get this error: Letter Box Camera has a depth of -100 and may conflict with the Letter Box Camera in Forced Camera Ratio! UnityEngine.Debug:LogError(Object) LetterboxCamera.ForceCameraRatio:Start() (at Assets/Auto Letterbox/ForceCameraRatio.cs:187) I am kind of a rookie so any advice would be super valuable! Thank you so much for your anwser! :)
@Rabidgremlin
@Rabidgremlin 7 жыл бұрын
You'll get that error if any other cameras in the scene have a Depth of -100. Check all the cameras in the scene. Generally you only need one (the Main Camera) and it should have a default depth of -1.
@abeloftmusic1948
@abeloftmusic1948 7 жыл бұрын
Rabidgremlin My only camera has depth of -1. The reason why I'm asking this because our game has been on play store for a few weeks now and in our latest update the letterbox camera doesnt work anymore. I have no idea what to do and this is really frustrating. Our players are asking why it isn't working anymore and I would really need help.
@Rabidgremlin
@Rabidgremlin 7 жыл бұрын
+Abeloft Music mmm, have you perhaps managed to create the component twice? Check through your hierarchy. When you run the scene in the editor check if multiple letterbox cameras are getting created.
@abeloftmusic1948
@abeloftmusic1948 7 жыл бұрын
Rabidgremlin wow it really creates two of them :o what can I do to fix this?
@Rabidgremlin
@Rabidgremlin 7 жыл бұрын
You will need to check all the objects in your hierarchy to see if you have managed to get the "Force Camera Ratio" script attached to more then one game object. Make sure there is only one such script attached to a game object in your scene.
@RavenFelman
@RavenFelman 7 жыл бұрын
It will this works fine also on mobile devices?
@Rabidgremlin
@Rabidgremlin 7 жыл бұрын
Yes it will.
@sebastianzogala8117
@sebastianzogala8117 6 жыл бұрын
Thank you.
@kajinx1848
@kajinx1848 6 жыл бұрын
I love you
@Victor-cn1ku
@Victor-cn1ku 5 жыл бұрын
LifeSaver.....
@jeannoeldallaire2669
@jeannoeldallaire2669 2 жыл бұрын
Great video, helped me tremendously
@Rabidgremlin
@Rabidgremlin 2 жыл бұрын
Glad it helped!
@parasyte8230
@parasyte8230 2 жыл бұрын
Thank you!!!
@wasituzayer9728
@wasituzayer9728 6 жыл бұрын
Can't I resize all the game objects in such a way that it fits all screen sizes... Cause I"m having problems with the black boxes... I need help, so please... reply
Creating a Google Cardboard VR app in Unity 2017 [RNDBITS-031]
17:08
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
Каха и дочка
00:28
К-Media
Рет қаралды 3,4 МЛН
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
Unity How to Lock Camera View to an Aspect Ratio and Add Black Bars
7:58
Creating Objects in Unity3D using the Factory Pattern
17:54
Jason Weimann (GameDev)
Рет қаралды 99 М.
Unity : Why the resolution of images should be a power of two.
9:03
about game making
Рет қаралды 6 М.
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 788 М.
RESOLUTION guide for game devs & GameMaker
8:50
Sara Spalding
Рет қаралды 72 М.
Creating an easy Ability System in Unity
7:08
TIMBER
Рет қаралды 106 М.
How to make Music for your Game - BOSCA CEOIL
11:20
Brackeys
Рет қаралды 806 М.
Understanding Orthographic Size in Unity
6:14
Press Start
Рет қаралды 86 М.
How To Fit Your Game For Every Resolution In Unity
7:32
Ido Asraff
Рет қаралды 45 М.
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН