private void DrawColorSpaceBox(Rect colorBoxRect, float constantValue) { if (Event.current.type != EventType.Repaint) { return; } if (this.m_ColorBoxMode != (ColorPicker.ColorBoxMode) this.m_TextureColorBoxMode) { int num = 8; int num2; if (this.m_ColorBoxMode == ColorPicker.ColorBoxMode.HV_S || this.m_ColorBoxMode == ColorPicker.ColorBoxMode.HS_V) { num2 = 64; } else { num2 = 8; } if (this.m_ColorBox == null) { this.m_ColorBox = ColorPicker.MakeTexture(num2, num); } if (this.m_ColorBox.width != num2 || this.m_ColorBox.height != num) { this.m_ColorBox.Resize(num2, num); } } if (this.m_ColorBoxMode != (ColorPicker.ColorBoxMode) this.m_TextureColorBoxMode || this.m_LastConstant != constantValue) { this.m_Colors = this.m_ColorBox.GetPixels(0); int width = this.m_ColorBox.width; int height = this.m_ColorBox.height; switch (this.m_ColorBoxMode) { case ColorPicker.ColorBoxMode.SV_H: ColorPicker.FillArea(width, height, this.m_Colors, new Color(this.m_H, 0f, 0f, 1f), new Color(0f, 1f, 0f, 0f), new Color(0f, 0f, 1f, 0f)); ColorPicker.HSVToRGBArray(this.m_Colors); break; case ColorPicker.ColorBoxMode.HV_S: ColorPicker.FillArea(width, height, this.m_Colors, new Color(0f, this.m_S, 0f, 1f), new Color(1f, 0f, 0f, 0f), new Color(0f, 0f, 1f, 0f)); ColorPicker.HSVToRGBArray(this.m_Colors); break; case ColorPicker.ColorBoxMode.HS_V: ColorPicker.FillArea(width, height, this.m_Colors, new Color(0f, 0f, this.m_V, 1f), new Color(1f, 0f, 0f, 0f), new Color(0f, 1f, 0f, 0f)); ColorPicker.HSVToRGBArray(this.m_Colors); break; case ColorPicker.ColorBoxMode.BG_R: ColorPicker.FillArea(width, height, this.m_Colors, new Color(this.m_R, 0f, 0f, 1f), new Color(0f, 0f, 1f, 0f), new Color(0f, 1f, 0f, 0f)); break; case ColorPicker.ColorBoxMode.BR_G: ColorPicker.FillArea(width, height, this.m_Colors, new Color(0f, this.m_G, 0f, 1f), new Color(0f, 0f, 1f, 0f), new Color(1f, 0f, 0f, 0f)); break; case ColorPicker.ColorBoxMode.RG_B: ColorPicker.FillArea(width, height, this.m_Colors, new Color(0f, 0f, this.m_B, 1f), new Color(1f, 0f, 0f, 0f), new Color(0f, 1f, 0f, 0f)); break; } if (QualitySettings.activeColorSpace == ColorSpace.Linear) { ColorPicker.LinearToGammaArray(this.m_Colors); } this.m_ColorBox.SetPixels(this.m_Colors, 0); this.m_ColorBox.Apply(true); this.m_LastConstant = constantValue; this.m_TextureColorBoxMode = (int)this.m_ColorBoxMode; } Graphics.DrawTexture(colorBoxRect, this.m_ColorBox, new Rect(0.5f / (float)this.m_ColorBox.width, 0.5f / (float)this.m_ColorBox.height, 1f - 1f / (float)this.m_ColorBox.width, 1f - 1f / (float)this.m_ColorBox.height), 0, 0, 0, 0, Color.grey); }
private void DrawColorSlider(Rect colorSliderRect, Vector2 constantValues) { if (Event.current.type != EventType.Repaint) { return; } if (this.m_ColorBoxMode != (ColorPicker.ColorBoxMode) this.m_TextureColorSliderMode) { int num = (int)this.m_ColorSliderSize; int num2; if (this.m_ColorBoxMode == ColorPicker.ColorBoxMode.SV_H) { num2 = 64; } else { num2 = (int)this.m_ColorSliderSize; } if (this.m_ColorSlider == null) { this.m_ColorSlider = ColorPicker.MakeTexture(num, num2); } if (this.m_ColorSlider.width != num || this.m_ColorSlider.height != num2) { this.m_ColorSlider.Resize(num, num2); } } if (this.m_ColorBoxMode != (ColorPicker.ColorBoxMode) this.m_TextureColorSliderMode || constantValues != this.m_LastConstantValues) { Color[] pixels = this.m_ColorSlider.GetPixels(0); int width = this.m_ColorSlider.width; int height = this.m_ColorSlider.height; switch (this.m_ColorBoxMode) { case ColorPicker.ColorBoxMode.SV_H: ColorPicker.FillArea(width, height, pixels, new Color(0f, 1f, 1f, 1f), new Color(0f, 0f, 0f, 0f), new Color(1f, 0f, 0f, 0f)); ColorPicker.HSVToRGBArray(pixels); break; case ColorPicker.ColorBoxMode.HV_S: ColorPicker.FillArea(width, height, pixels, new Color(this.m_H, 0f, Mathf.Max(this.m_V, 0.3f), 1f), new Color(0f, 0f, 0f, 0f), new Color(0f, 1f, 0f, 0f)); ColorPicker.HSVToRGBArray(pixels); break; case ColorPicker.ColorBoxMode.HS_V: ColorPicker.FillArea(width, height, pixels, new Color(this.m_H, this.m_S, 0f, 1f), new Color(0f, 0f, 0f, 0f), new Color(0f, 0f, 1f, 0f)); ColorPicker.HSVToRGBArray(pixels); break; case ColorPicker.ColorBoxMode.BG_R: ColorPicker.FillArea(width, height, pixels, new Color(0f, this.m_G, this.m_B, 1f), new Color(0f, 0f, 0f, 0f), new Color(1f, 0f, 0f, 0f)); break; case ColorPicker.ColorBoxMode.BR_G: ColorPicker.FillArea(width, height, pixels, new Color(this.m_R, 0f, this.m_B, 1f), new Color(0f, 0f, 0f, 0f), new Color(0f, 1f, 0f, 0f)); break; case ColorPicker.ColorBoxMode.RG_B: ColorPicker.FillArea(width, height, pixels, new Color(this.m_R, this.m_G, 0f, 1f), new Color(0f, 0f, 0f, 0f), new Color(0f, 0f, 1f, 0f)); break; } if (QualitySettings.activeColorSpace == ColorSpace.Linear) { ColorPicker.LinearToGammaArray(pixels); } this.m_ColorSlider.SetPixels(pixels, 0); this.m_ColorSlider.Apply(true); } Graphics.DrawTexture(colorSliderRect, this.m_ColorSlider, new Rect(0.5f / (float)this.m_ColorSlider.width, 0.5f / (float)this.m_ColorSlider.height, 1f - 1f / (float)this.m_ColorSlider.width, 1f - 1f / (float)this.m_ColorSlider.height), 0, 0, 0, 0, Color.grey); }