controlling resolution and quality setting using UI Slider?

I want to control quality setting and resolution using unity 5’s UI Slider .Now i can change those setting using buttons , tap 720p button to set resolution as 720p , tap 1080p button to set resolution as 1080p and tap low button to set quality setting as fastest and tap high button to set as fantastic but i want to control those setting using UI Slider, PLZ HELP

Add a slider, set min and max value (for example 0-5 for 6 different quality levels), check ‘whole numbers’ and add a function that is called on value changed (dynamic float) like:

public void ChangeQuality(float level)
{
     switch((int)level)
     {
          case 0:
          // set values for quality level 0 here
          break;
          case 1:
          // set values for quality level 1 here
          break;
          ...
      }
}