public void OnEnable()
    {
        //initialize object
        vals = new SettingVars();

        //assigning delegates [functions]
        AntiAliasingTypeDropDown.onValueChanged.AddListener(delegate { OnAntiAliasingTypeChange(); });
        AntiAliasingQualityDropDown.onValueChanged.AddListener(delegate { OnAntiAliasingQualityChange(); });
        ResolutionDropDown.onValueChanged.AddListener(delegate { OnResolutionChange(); });
        TexQualityDropDown.onValueChanged.AddListener(delegate { OnTexQualityChange(); });
        ShadowTypeDropDown.onValueChanged.AddListener(delegate { OnShadowTypeChange(); });
        ShadowResDropDown.onValueChanged.AddListener(delegate { OnShadowResChange(); });
        VSyncDropDown.onValueChanged.AddListener(delegate { OnVSyncChange(); });
        AmbientOcclusionToggle.onValueChanged.AddListener(delegate { OnAmbientOcclusionChange(); });
        MotionBlurToggle.onValueChanged.AddListener(delegate { OnMotionBlurChange(); });
        BloomToggle.onValueChanged.AddListener(delegate { OnBloomChange(); });
        ColorGradingToggle.onValueChanged.AddListener(delegate { OnColorGradingChange(); });
        ChromaticAberrationToggle.onValueChanged.AddListener(delegate { OnChromaticAberrationChange(); });
        DitheringToggle.onValueChanged.AddListener(delegate { OnDitheringChange(); });

        //Add all resolutions supported by the screen in the dropdown
        SupportedResolutions = Screen.resolutions;
        foreach (Resolution resolution in SupportedResolutions)
        {
            ResolutionDropDown.options.Add(new Dropdown.OptionData(resolution.ToString()));
        }

        //Loading the settings
        LoadSettings();
    }
 public void LoadSettings()
 {
     if (Application.isEditor)
     {
         if (!File.Exists(Application.persistentDataPath + "/gamesettings.json"))
         {
             AntiAliasingTypeDropDown.value    = vals.AntiAliasingType = AntiAliasingType();
             AntiAliasingQualityDropDown.value = vals.AntiAliasingQuality = AntiAliasingQuality();
             ResolutionDropDown.value          = vals.Resolutions = FindCurrentResolution();
             TexQualityDropDown.value          = vals.TexQuality = QualitySettings.masterTextureLimit;
             ShadowTypeDropDown.value          = vals.ShadowType = ShadowType();
             ShadowResDropDown.value           = vals.ShadowRes = ShadowRes();
             VSyncDropDown.value            = vals.VSyncs = QualitySettings.vSyncCount;
             AmbientOcclusionToggle.isOn    = Pprofile.ambientOcclusion.enabled;
             MotionBlurToggle.isOn          = Pprofile.motionBlur.enabled;
             BloomToggle.isOn               = Pprofile.bloom.enabled;
             ColorGradingToggle.isOn        = Pprofile.colorGrading.enabled;
             ChromaticAberrationToggle.isOn = Pprofile.chromaticAberration.enabled;
             DitheringToggle.isOn           = Pprofile.dithering.enabled;
             string jsonData = JsonUtility.ToJson(vals, true);
             File.WriteAllText(Application.persistentDataPath + "/gamesettings.json", jsonData);
         }
         else
         {
             vals = JsonUtility.FromJson <SettingVars>(File.ReadAllText(Application.persistentDataPath + "/gamesettings.json"));
             AntiAliasingTypeDropDown.value    = vals.AntiAliasingType;
             AntiAliasingQualityDropDown.value = vals.AntiAliasingQuality;
             ResolutionDropDown.value          = vals.Resolutions;
             TexQualityDropDown.value          = vals.TexQuality;
             ShadowTypeDropDown.value          = vals.ShadowType;
             ShadowResDropDown.value           = vals.ShadowRes;
             VSyncDropDown.value            = vals.VSyncs;
             AmbientOcclusionToggle.isOn    = Pprofile.ambientOcclusion.enabled;
             MotionBlurToggle.isOn          = Pprofile.motionBlur.enabled;
             BloomToggle.isOn               = Pprofile.bloom.enabled;
             ColorGradingToggle.isOn        = Pprofile.colorGrading.enabled;
             ChromaticAberrationToggle.isOn = Pprofile.chromaticAberration.enabled;
             DitheringToggle.isOn           = Pprofile.dithering.enabled;
         }
     }
     else
     {
         if (!File.Exists(Application.persistentDataPath + "/actualstandalonesettings.json"))
         {
             AntiAliasingTypeDropDown.value    = vals.AntiAliasingType = AntiAliasingType();
             AntiAliasingQualityDropDown.value = vals.AntiAliasingQuality = AntiAliasingQuality();
             ResolutionDropDown.value          = vals.Resolutions = FindCurrentResolution();
             TexQualityDropDown.value          = vals.TexQuality = QualitySettings.masterTextureLimit;
             ShadowTypeDropDown.value          = vals.ShadowType = ShadowType();
             ShadowResDropDown.value           = vals.ShadowRes = ShadowRes();
             VSyncDropDown.value            = vals.VSyncs = QualitySettings.vSyncCount;
             AmbientOcclusionToggle.isOn    = Pprofile.ambientOcclusion.enabled;
             MotionBlurToggle.isOn          = Pprofile.motionBlur.enabled;
             BloomToggle.isOn               = Pprofile.bloom.enabled;
             ColorGradingToggle.isOn        = Pprofile.colorGrading.enabled;
             ChromaticAberrationToggle.isOn = Pprofile.chromaticAberration.enabled;
             DitheringToggle.isOn           = Pprofile.dithering.enabled;
             string jsonData = JsonUtility.ToJson(vals, true);
             File.WriteAllText(Application.persistentDataPath + "/actualstandalonesettings.json", jsonData);
         }
         else
         {
             vals = JsonUtility.FromJson <SettingVars>(File.ReadAllText(Application.persistentDataPath + "/actualstandalonesettings.json"));
             AntiAliasingTypeDropDown.value    = vals.AntiAliasingType;
             AntiAliasingQualityDropDown.value = vals.AntiAliasingQuality;
             ResolutionDropDown.value          = vals.Resolutions;
             TexQualityDropDown.value          = vals.TexQuality;
             ShadowTypeDropDown.value          = vals.ShadowType;
             ShadowResDropDown.value           = vals.ShadowRes;
             VSyncDropDown.value            = vals.VSyncs;
             AmbientOcclusionToggle.isOn    = Pprofile.ambientOcclusion.enabled;
             MotionBlurToggle.isOn          = Pprofile.motionBlur.enabled;
             BloomToggle.isOn               = Pprofile.bloom.enabled;
             ColorGradingToggle.isOn        = Pprofile.colorGrading.enabled;
             ChromaticAberrationToggle.isOn = Pprofile.chromaticAberration.enabled;
             DitheringToggle.isOn           = Pprofile.dithering.enabled;
         }
     }
 }