public void SaveOptionsToPlayerPrefs() { var sliders = optionCanvas.gameObject.GetComponentsInChildren <Slider>(); foreach (var slider in sliders) { if (slider.name == "Sld_MusicVol") { prefsControl.SetMusicVolume(slider.value); } else if (slider.name == "Sld_SFXVol") { prefsControl.SetSfxVolume(slider.value); } } var toggles = optionCanvas.gameObject.GetComponentsInChildren <Toggle>(); foreach (var toggle in toggles) { if (toggle.name == "Tog_AutoFire") { prefsControl.SetAutoFire(toggle.isOn); } else if (toggle.name == "Tog_Accelerometer") { prefsControl.SetAccelerometer(toggle.isOn); } } }