- Home /
How to convert a list of Resolution to String
Hi guys... First of all, i'm Brazilian and i'm sorry about my bad english...
I am creating a PopUp Menu that shows all the resolutions supported by the monitor... To do this, i created a List of Resolution called resolutions and added the items after the foreach (Resolution res in resolutions)... Ok... Now i need to convert these resolutions to a string and add these string in other List of string... I can't add these items of the List because the other List is List, and when i put the .toString(), the console doesn't show the resolutions for me... The console shows me this (UnityEngine.Resolution)...
My code:
 private UIPopupList uiPopUpScript;
 public List<Resolution> resolutionsList;
 
     // Use this for initialization
     void Start() {
         uiPopUpScript = GetComponent<UIPopupList>();
         resolutionsList = new List<Resolution>();
 
         Resolution[] resolutions = Screen.resolutions;
         foreach (Resolution res in resolutions) {
             resolutionsList.Add(res);
         }
             uiPopUpScript.item = resolutionsList.ToString();     // This uiPopUpScript.item is the List of string that i need to put all the resolutions... But this way, the console shows me this:
[UnityEngine.Resolution][1] [1]: http://i61.tinypic.com/2hcpwt2_th.png
     }
Answer by zharik86 · Jul 28, 2014 at 07:05 PM
If you want see resolutions in string format and create it in list, see below simple script:
  public List<Resolution> resolutionsList = new List<Resolution>();
  public List<string> resString = new List<string>;
  void Start() {
   Resolution[] resolutions = Screen.resolutions; //all resolution
   foreach (Resolution res in resolutions) { see everyone resolution in array
    resolutionsList.Add(res); //add resolution in list
    resString.Add(res.width.toString() + "x" + res.height.toString()); //string format every resolution
   }
  }
I hope it will help you.
Answer by codejunkie83 · Jul 28, 2014 at 07:13 PM
You should use the members of the Resolution class to construct a string to insert. For instance:
 resolutionsList.Add(res.width + "x" + res.height + "x" + res.refreshRate);
Your answer
 
 
             Follow this Question
Related Questions
How to make a refresh rate dropdown menu? 1 Answer
Most efficient way to convert string[] to int [] in C#? 2 Answers
Convert Text to float 3 Answers
Converting 1s and 0s to float 1 Answer
Cast the result of an enum as a string 3 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                