public void PreparePicker(Transform owner, Color col) { //TODO: CLEAN THIS UP AND FIX EVENT MANAGEMENT _owner = owner; _picker = transform.GetChild(2).GetChild(0); _HueSlider = transform.GetChild(0).GetComponent <Slider>(); _valueSlider = transform.GetChild(1).GetComponent <Slider>(); _pickManager = GameObject.FindWithTag("GameController").GetComponent <ColorPickerManager>(); _currentColor = col; ColorHSV color = new ColorHSV(_currentColor); _HueSlider.value = color.h; Hue = (int)_HueSlider.value; _valueSlider.value = color.v; Value = (int)_valueSlider.value; _pickManager.GenerateColorTexture(Hue); _picker.localPosition = new Vector3(color.s, color.v); _picker.GetChild(0).GetComponent <Image>().color = _currentColor; var texture = _pickManager.GetHeuTexture2D(); transform.GetChild(0).GetChild(0).GetComponent <Image>().sprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100.0f); texture = _pickManager.GetSatuartionTexture2D(); transform.GetChild(1).GetChild(0).GetComponent <Image>().sprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100.0f); _colorTexture2D = _pickManager.GetColorTexture2D(); transform.GetChild(2).GetComponent <Image>().sprite = Sprite.Create(_colorTexture2D, new Rect(0.0f, 0.0f, _colorTexture2D.width, _colorTexture2D.height), new Vector2(0.5f, 0.5f), 100.0f); }
public void SetHeu(Slider slider) { _HueSlider = slider; Hue = (int)slider.value; if (_pickManager) { _pickManager.GenerateColorTexture(Hue); _colorTexture2D = _pickManager.GetColorTexture2D(); transform.GetChild(2).GetComponent <Image>().sprite = Sprite.Create(_colorTexture2D, new Rect(0.0f, 0.0f, _colorTexture2D.width, _colorTexture2D.height), new Vector2(0.5f, 0.5f), 100.0f); var x = Mathf.Clamp(_picker.localPosition.x, 0, 0.99f); var y = Mathf.Clamp(_picker.localPosition.y, 0, 0.99f); _currentColor = _colorTexture2D.GetPixelBilinear(x, y); _picker.GetChild(0).GetComponent <Image>().color = _currentColor; } }