Тёмный

Unity: Resolution Dropdown 

Root Games
Подписаться 3,8 тыс.
Просмотров 24 тыс.
50% 1

Learn how to create a resolution dropdown in Unity.
✅ Get my courses with discount:
👉 Unity 2D Master: www.udemy.com/course/unity2dm...
👉 Unity Mobile Course: www.udemy.com/course/unitymob...
👉 Unity Input System with Rebinding: www.udemy.com/course/unity-in...
👍 Save your time and learn Unity faster
-------------------------------------------------------
🔔 Subscribe for more awesome content:
🔴 / @rootgames
-------------------------------------------------------
🟡 Support this channel through donations
Any amount means a lot and will help grow the channel:
👉 PayPal: www.paypal.com/paypalme/rootg...
-------------------------------------------------------
Social Networks:
⭐ Instagram: / rootgamesofficial
⭐ Twitter: / rootgamescro
⭐ TikTok: www.tiktok.com/@rootgamesoffi...
⭐ Facebook: / root-games-10337038860...
-------------------------------------------------------
#unity #resolution #settings #unitytutorial

Опубликовано:

 

30 сен 2022

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 73   
@RootGames
@RootGames Год назад
✅ Get my courses with discount: 👉 Unity 2D Master: www.udemy.com/course/unity2dmaster/?couponCode=SMOOTH-2D-MASTER 👉 Unity Mobile Course: www.udemy.com/course/unitymobilecourse/?couponCode=SMOOTH-MOBILE 👉 Unity Input System with Rebinding: www.udemy.com/course/unity-input-system-rebind/?couponCode=SMOOTH-OFFER-INPUT
@TripalYT
@TripalYT Год назад
Thanks for this, the listings of all refresh rates was always so cluttering and this fixed that!
@gabrielandraderosa8622
@gabrielandraderosa8622 3 месяца назад
To fix the obsolete problem: change the line 20 to currentRefreshRate = (float)Screen.currentResolution.refreshRateRatio.value;.
@madmanga64
@madmanga64 Год назад
Quick and easy to follow thanks!
@rodriferg
@rodriferg 6 месяцев назад
Thanks for this tutorial! You helped me to fix our resolution system ^^
@jozsefacs2224
@jozsefacs2224 Год назад
Thankyou for the good tutorial from al of the tutorials this is the only one i can follow easy haha. Keep up the good work !
@RootGames
@RootGames Год назад
Thanks 😀
@acarius4747
@acarius4747 Год назад
That helped a lot, thanks buddy
@felipeagudelo76
@felipeagudelo76 Год назад
Excelente muchas gracias
@volverte7908
@volverte7908 Год назад
Thank you!!!
@castlecodersltd
@castlecodersltd Месяц назад
Nice one, thanks😊
@cristiangenete8734
@cristiangenete8734 Год назад
Thank you for the tutorial! It works.
@RootGames
@RootGames Год назад
You're welcome! :D
@Kaldrin
@Kaldrin 3 месяца назад
Thanks man
@pushthebutton4602
@pushthebutton4602 Год назад
Hi there, thank you for this, how do I implement Windowed checkbox?
@Simulatech
@Simulatech Год назад
is there a way of doing this without the capped refresh rate?
@Ocer.
@Ocer. 9 месяцев назад
Incredibly simple tutorial and well written code
@RootGames
@RootGames 9 месяцев назад
Thanks ❤️
@Xitman239
@Xitman239 Год назад
Почему у меня такая ошибка? Cannot convert source type 'UnityEngine.RefreshRate' to target type 'float'
@ShidaPenns
@ShidaPenns Год назад
Okay, with ChatGPT's help I finally figured out how to convert a refresh rate int, like 60, to the RefreshRate type it's saying you need for the fourth SetResolution argument. I'm a beginner so I'm proud of this. 😂 (ChatGPT was helpful in the end but holy crap did it give me a lot of wrong answers.) rRate is my refresh rate int, here. And width and height are the resolution sizes, naturally. // create a new RefreshRate instance RefreshRate refreshRate = new RefreshRate(); // set the numerator and denominator properties separately refreshRate.numerator = (uint)rRate; refreshRate.denominator = 1; // Set the display resolution to the selected resolution and refresh rate Screen.SetResolution(width, height, FullScreenMode.ExclusiveFullScreen, refreshRate);
@Armaan8014
@Armaan8014 Год назад
What if we want the text to be a label/TMPro text instead of a dropdown like this video? ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE--Zwk-C0BtEU.html The resolution.AddOptions(options) etc parts dont work - what could be the substitute then?
@dmitrycherkashin
@dmitrycherkashin 2 месяца назад
set the variable "currentRefreshRate" to int, not a float and you do not the get any bugs with resolutions in dropdown. Sry for my english.
@briangular2115
@briangular2115 Год назад
excellent tutorial, clearly explained
@RootGames
@RootGames Год назад
Thanks 🙂
@vistitol
@vistitol Год назад
Hello. Good tutorial but i have a question, what happen if you hav more than one monitor??? This method is shoings the Resolution of the principal monitor or the Resolution of the monitor where the game is playing??? Thanks.
@RootGames
@RootGames Год назад
Thanks! This will show resolution of the monitor where you open the game.
@ThatRazzy
@ThatRazzy Год назад
@@RootGames Hi there, thank you for the great tutorial. So I'm having a similar issue to the one @vistitol mentioned. No matter which monitor I open the game on, I believe the filtered resolutions list only includes the resolutions/framerates of my main display. My main display is at 60hz and my secondary is at 144hz. Because the list of filtered resolutions only includes those of my main display (I'm assuming), launching the game on my second monitor causes the following error: ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index Do you have any suggestions on how to fix this/populate the list with the resolutions/framerates of all connected displays? Thank you in advance!
@unknxwn7381
@unknxwn7381 8 месяцев назад
For some mine works in the editor only and not in the build, i followed step by step
@Eastyoffutt
@Eastyoffutt Год назад
Why does mine glitch on top of each other
@alice0067
@alice0067 Год назад
i am having a problem with the resolution settings, its working fine in my editor but when i run it in my phone, i can see only one resolution which is the current resolution of my screen. I cant see any other resolutions from that dropdown.
@RootGames
@RootGames Год назад
I'm not sure that this works for phones.
@nexotin
@nexotin Год назад
I dont know how to fix the Error... Assets\Scripts\Resolution.cs(51,53): error CS1061: 'Resolution' does not contain a definition for 'height' and no accessible extension method 'height' accepting a first argument of type 'Resolution' could be found (are you missing a using directive or an assembly reference?)
@mandrutalol3631
@mandrutalol3631 3 месяца назад
I have the same issue
@mandrutalol3631
@mandrutalol3631 3 месяца назад
I found the fix, its because i had named my script "Resolution". I changed it smth else and it was solved
@TegridyMadeGames
@TegridyMadeGames Год назад
thank you so much!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@amees89
@amees89 Год назад
Hi nice Video! I have a problem tho, the Dropdown menu wont change my Resolution. Its stuck at 600x480 or something and even if I change it to 1920x1080 its still not changing. do you have a solution?
@llibertii
@llibertii Год назад
Take a closer look at the line 35 of the tutorial you probably didn't change the resoltutions to filteredResolutions. I had the same issue since instead of rewritting the entire script I just tried to fix the one I had and forgot to change that but luckily I managed to figure that out. Hope that helps!
@TheGamingDelphox
@TheGamingDelphox Год назад
The dropdown box always starts at 640x480 60hz (The First Option) even though the build is actually in 1920 x 1080 60hz. Is there a way to fix this?
@voxelzombie6238
@voxelzombie6238 Год назад
i also have this problem
@TheGamingDelphox
@TheGamingDelphox Год назад
@@voxelzombie6238 I think I fixed it. I replaced "resolutionDropdown.value = currentResolutionIndex;" with "resolutionDropdown.value = Mathf.Max(options.Count);". currentResolutionIndex had a value of 0, setting the dropdown to the smallest resolution, the new line of code sets the value to the highest amount based on the number of options present.
@Simulatech
@Simulatech Год назад
@@TheGamingDelphox thank you
@sundee7371
@sundee7371 3 месяца назад
If you replace it the "currentResolutionIndex" becomes useless. It works perfectly fine for me. I am using a Playerprefs.
@ZPanda13
@ZPanda13 8 месяцев назад
Idk why, but it shows every resolution except my highest one 1920x1080 (the one I actually run on). it shows 1650x1050 being the highest.
@credormk5770
@credormk5770 7 месяцев назад
Maybe is late but i think it could be the filter by refresh rate.
@castlecodersltd
@castlecodersltd Месяц назад
Is that in the editor? That's the size of the resolution when running from there. Try running a build
@Mr.Legend360
@Mr.Legend360 5 месяцев назад
can you provide me script plz i cant see because font size is too small plz bro i will be very thanksful to you plz
@TegridyMadeGames
@TegridyMadeGames Год назад
Had an issue where it would make each resolution 5 times after building, i guess for variable refresh rates (which i really did NOT want lol) Heres a fix if anyone need it, checks for duplicate resolutions sizes: using System.Linq; //this first line is a reference of where to add it in the script currentRefreshRate = Screen.currentResolution.refreshRate; //this is the actual loop check for (int i = 0; i < resolutions.Length; i++) { if (!filteredResolutions.Any(x => x.width == resolutions[i].width && x.height == resolutions[i].height)) //check if resolution already exists in list { filteredResolutions.Add(resolutions[i]); //add resolution to list if it doesn't exist yet } }
@jaguar1822
@jaguar1822 9 месяцев назад
Thanks a lot, this helps with the issue of repeated resolutions :D
@Markleap
@Markleap Год назад
everything is the same but still dont work
@turkmitolojioyunu
@turkmitolojioyunu Месяц назад
The correct code; 👉 using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class SettingsResolution : MonoBehaviour { [SerializeField] private TMP_Dropdown resolutionDropdown; private Resolution[] resolutions; private List filteredResolutions; private float currentRefreshRate; private int currentResolutionIndex = 0; void Start() { resolutions = Screen.resolutions; filteredResolutions = new List(); resolutionDropdown.ClearOptions(); currentRefreshRate = (float)Screen.currentResolution.refreshRateRatio.value; for (int i = 0; i < resolutions.Length; i++) { if ((float)resolutions[i].refreshRateRatio.value == currentRefreshRate) { filteredResolutions.Add(resolutions[i]); } } filteredResolutions.Sort((a, b) => { if (a.width != b.width) return b.width.CompareTo(a.width); else return b.height.CompareTo(a.height); }); List options = new List(); for (int i = 0; i < filteredResolutions.Count; i++) { string resolutionOption = filteredResolutions[i].width + "x" + filteredResolutions[i].height + " " + filteredResolutions[i].refreshRateRatio.value.ToString("0.##") + " Hz"; // Ondalık basamak sınırlandı options.Add(resolutionOption); if (filteredResolutions[i].width == Screen.width && filteredResolutions[i].height == Screen.height && (float)filteredResolutions[i].refreshRateRatio.value == currentRefreshRate) // double'dan float'a dönüştürüldü { currentResolutionIndex = i; } } resolutionDropdown.AddOptions(options); resolutionDropdown.value = currentResolutionIndex = 0; resolutionDropdown.RefreshShownValue(); SetResolution(currentResolutionIndex); } public void SetResolution(int resolutionIndex) { Resolution resolution = filteredResolutions[resolutionIndex]; Screen.SetResolution(resolution.width, resolution.height, true); } } 👈
@limasapenas
@limasapenas 5 месяцев назад
Thanks for the help, my only criticism is that you overestimates the viewer intelligence, so I think you should talk about the minor things you did that you speed up, just so I don't need to go back to see exactly what you did, but besides that, it's a great tutorial.
@uluc0
@uluc0 2 месяца назад
Skill issue
@pankulas
@pankulas Год назад
Ok but how to use it in build
@RootGames
@RootGames Год назад
Use the same code as in the tutorial
@pankulas
@pankulas Год назад
@@RootGames how to make it change actual resolution
@RootGames
@RootGames Год назад
@@pankulas Don't understand you. It actually changes the resolution in the build.
@maximtarna6669
@maximtarna6669 Год назад
not working :/
@RootGames
@RootGames Год назад
It works. Double check your code. Also, try setting the "currentRefreshRate" variable manually, for example, set it to 60 and you'll only get resolutions with that refresh rate. As I said in the video, you need to make a build to test it correctly.
@puriceful
@puriceful Год назад
non funziona neanche questo😔
@legionofregion8825
@legionofregion8825 3 месяца назад
SLOW DOWN
@ziadmouad5889
@ziadmouad5889 Год назад
hi i need the code in Reply
@RootGames
@RootGames Год назад
I don't have the code to copy-paste it but you will learn more if you follow the tutorial and try to write it step by step. Trust me, avoid copy paste without understanding the logic behind the code.
@ziadmouad5889
@ziadmouad5889 Год назад
​@@RootGames thank you sir for the advice
@talismanskulls2857
@talismanskulls2857 Год назад
Well this sucks if you dont want to use Dropdowns.
@RootGames
@RootGames Год назад
Well you can modify the code and use it in other ways. You can go through elements by clicking left/right buttons. Play a little bit with the code.
@talismanskulls2857
@talismanskulls2857 Год назад
@@RootGames I been trying for 2 weeks now. I am failing badly.
@Jelandro_sander
@Jelandro_sander 5 месяцев назад
obsolet
@gabrielandraderosa8622
@gabrielandraderosa8622 3 месяца назад
change the line 20 to currentRefreshRate = (float)Screen.currentResolution.refreshRateRatio.value;
Далее
Learn INTERFACES in 5 minutes | Unity
5:38
Просмотров 4,2 тыс.
SETTINGS MENU in Unity
17:22
Просмотров 934 тыс.
ВОТ ЧТО МЫ КУПИЛИ НА ALIEXPRESS
09:35
What size should your assets be? | HD 2D GAME ART
12:10
Learning C# In A Week... Otherwise I Fail University
9:04
Top 10 Tips To Optimize Your Mobile Game - Unity 3D
8:06
The Power of Scriptable Objects as Middle-Men
17:41
Просмотров 121 тыс.
RESOLUTION guide for game devs & GameMaker
8:50
Просмотров 55 тыс.
Why you should use code to animate your UI in Unity.
5:02