Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Ceneu · May 30 at 02:39 AM · listresolutionresolution settingsresolutions

Resolutions duplicates in options menu

I am getting some resolutions duplicates because of the HZ. How can I make a system that detects the lowest hz in the resolutions profile with this code?

  using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
   namespace AkshayDhotre.GraphicSettingsMenu
    {
   /// <summary>
   /// Inherits from the Option class
   /// This class handles the resolution options
   /// </summary>
   public class ResolutionOption : Option
    {
     
     private void Awake()
     {
         Initialize();
     }

     private void Initialize()
     {
         GenerateResolutionSubOptions();

         //Assign the first element from the suboption list as the current option
         //We check if the current suboption is null because if we load the data from the xml file, the currentsuboption will be assigned 
         //and we don't want to reassign it.
         if (currentSubOption.name == "" && subOptionList.Count > 0)
         {
             currentSubOptionIndex = 0;
             currentSubOption = subOptionList[currentSubOptionIndex];
             
         }

         UpdateSuboptionText();
     }

     /// <summary>
     /// Applies the resolution settings
     /// from the xml file
     /// </summary>
     public override void Apply()
     {
         GraphicSettingHelperMethods.ChangeResolution((int)currentSubOption.vector2Value.x, (int)currentSubOption.vector2Value.y);
     }

     /// <summary>
     /// Gets the available resolution from Screen.resolutions and creates the suboptions list containing the availables resolutions
     /// </summary>
     private void GenerateResolutionSubOptions()
     {
         //Clear/Empty the list
         subOptionList.Clear();


         //Cycle through each resolution in Screen.resolutions and create a new suboption with the corresponding names, values and the index
         //Then add that suboption to the suboption list
         int i = 0;
         foreach(Resolution r in Screen.resolutions)
         {
             SubOption t = new SubOption();
             t.name = r.width.ToString() + "x" + r.height.ToString();
             t.vector2Value = new Vector2(r.width, r.height);
             t.indexInList = i;
             subOptionList.Add(t);
             i++;
         }
     }

     /// <summary>
     /// Goes through the list of the resolution and then finds the suboption which has value equal to the input value
     /// and assigns that sub option as the current sub option
     /// </summary>
     /// <param name="v"></param>
     public void SetCurrentsuboptionByValue(Vector2 v)
     {
         if(subOptionList.Count > 0)
         {
             foreach(var t in subOptionList)
             {
                 if(t.vector2Value == v)
                 {
                     currentSubOption = t;
                     currentSubOptionIndex = t.indexInList;
                     UpdateSuboptionText();
                     return;
                 }
             }

             //If no item is found then we use the fall back option
             Debug.LogWarning("Suboption with value : " + v + " ,not found in :" + gameObject.name + ",using fallback option instead");
             currentSubOption = fallBackOption;
             currentSubOptionIndex = fallBackOption.indexInList;
         }
         else
         {
             Debug.LogError("No items in suboption list : " + gameObject.name);
         }
     }
 }

}

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

141 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Resolution being saved as 0x0 0 Answers

Unity Resolution Limit 2 Answers

Standard Asset joystick has issues when using custom resolution 1 Answer

A node in a childnode? 1 Answer

Resolution is not saving. 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges