public void GenerateChangeColors() { System.Func <Color, Color> generator; float maxChange0 = firstAbsoluteColorComponentSlider.gameObject.activeSelf ? firstAbsoluteColorComponentSlider.value : 0f; float maxChange1 = secondAbsoluteColorComponentSlider.gameObject.activeSelf ? secondAbsoluteColorComponentSlider.value : 0f; float maxChange2 = thirdAbsoluteColorComponentSlider.gameObject.activeSelf ? thirdAbsoluteColorComponentSlider.value : 0f; float maxChange3 = fourthAbsoluteColorComponentSlider.gameObject.activeSelf ? fourthAbsoluteColorComponentSlider.value : 0f; if (rgbToggle.isOn) { generator = (Color color) => _random.ColorRGBShift(color, maxChange0, maxChange1, maxChange2); } else if (cmyToggle.isOn) { generator = (Color color) => (Color)_random.ColorCMYShift(color, maxChange0, maxChange1, maxChange2); } else if (cmykToggle.isOn) { generator = (Color color) => (Color)_random.ColorCMYKShift(color, maxChange0, maxChange1, maxChange2, maxChange3); } else if (hsvToggle.isOn) { generator = (Color color) => (Color)_random.ColorHSVShift(color, maxChange0, maxChange1, maxChange2); } else if (hslToggle.isOn) { generator = (Color color) => (Color)_random.ColorHSLShift(color, maxChange0, maxChange1, maxChange2); } else if (hsyToggle.isOn) { generator = (Color color) => (Color)_random.ColorHSYShift(color, maxChange0, maxChange1, maxChange2); } else if (hcvToggle.isOn) { generator = (Color color) => (Color)_random.ColorHCVShift(color, maxChange0, maxChange1, maxChange2); } else if (hclToggle.isOn) { generator = (Color color) => (Color)_random.ColorHCLShift(color, maxChange0, maxChange1, maxChange2); } else if (hcyToggle.isOn) { generator = (Color color) => (Color)_random.ColorHCYShift(color, maxChange0, maxChange1, maxChange2); } else { throw new System.NotImplementedException(); } Color selectedColor = _selectedColorButton.colorImage.color; foreach (ColorToggleButton colorButton in _colorButtons) { if (colorButton != _selectedColorButton) { colorButton.colorImage.color = generator(selectedColor); } } }