public static void DrawPreview(Rect position) { if (Event.current.type != EventType.Repaint) { return; } if (EyeDropper.styles == null) { EyeDropper.styles = new EyeDropper.Styles(); } Texture2D texture2D = EyeDropper.get.m_Preview; int num1 = (int)Mathf.Ceil(position.width / 10f); int num2 = (int)Mathf.Ceil(position.height / 10f); if ((Object)texture2D == (Object)null) { EyeDropper.get.m_Preview = texture2D = ColorPicker.MakeTexture(num1, num2); texture2D.filterMode = UnityEngine.FilterMode.Point; } if (texture2D.width != num1 || texture2D.height != num2) { texture2D.Resize(num1, num2); } Vector2 screenPoint = GUIUtility.GUIToScreenPoint(Event.current.mousePosition); Vector2 pixelPos = screenPoint - new Vector2((float)(num1 / 2), (float)(num2 / 2)); texture2D.SetPixels(InternalEditorUtility.ReadScreenPixel(pixelPos, num1, num2), 0); texture2D.Apply(true); Graphics.DrawTexture(position, (Texture)texture2D); float width = position.width / (float)num1; GUIStyle dropperVerticalLine = EyeDropper.styles.eyeDropperVerticalLine; float x = position.x; while ((double)x < (double)position.xMax) { Rect position1 = new Rect(Mathf.Round(x), position.y, width, position.height); dropperVerticalLine.Draw(position1, false, false, false, false); x += width; } float height = position.height / (float)num2; GUIStyle dropperHorizontalLine = EyeDropper.styles.eyeDropperHorizontalLine; float y = position.y; while ((double)y < (double)position.yMax) { Rect position1 = new Rect(position.x, Mathf.Floor(y), position.width, height); dropperHorizontalLine.Draw(position1, false, false, false, false); y += height; } Rect position2 = new Rect((screenPoint.x - pixelPos.x) * width + position.x, (screenPoint.y - pixelPos.y) * height + position.y, width, height); EyeDropper.styles.eyeDropperPickedPixel.Draw(position2, false, false, false, false); }
public static void DrawPreview(Rect position) { if (Event.current.type != EventType.Repaint) { return; } if (EyeDropper.styles == null) { EyeDropper.styles = new EyeDropper.Styles(); } GL.sRGBWrite = (QualitySettings.activeColorSpace == ColorSpace.Linear); Texture2D texture2D = EyeDropper.get.m_Preview; int num = (int)Mathf.Ceil(position.width / 10f); int num2 = (int)Mathf.Ceil(position.height / 10f); if (texture2D == null) { texture2D = (EyeDropper.get.m_Preview = ColorPicker.MakeTexture(num, num2)); texture2D.filterMode = FilterMode.Point; } if (texture2D.width != num || texture2D.height != num2) { texture2D.Resize(num, num2); } Vector2 a = GUIUtility.GUIToScreenPoint(Event.current.mousePosition); Vector2 pixelPos = a - new Vector2((float)(num / 2), (float)(num2 / 2)); texture2D.SetPixels(InternalEditorUtility.ReadScreenPixel(pixelPos, num, num2), 0); texture2D.Apply(true); Graphics.DrawTexture(position, texture2D); float num3 = position.width / (float)num; GUIStyle gUIStyle = EyeDropper.styles.eyeDropperVerticalLine; for (float num4 = position.x; num4 < position.xMax; num4 += num3) { Rect position2 = new Rect(Mathf.Round(num4), position.y, num3, position.height); gUIStyle.Draw(position2, false, false, false, false); } float num5 = position.height / (float)num2; gUIStyle = EyeDropper.styles.eyeDropperHorizontalLine; for (float num6 = position.y; num6 < position.yMax; num6 += num5) { Rect position3 = new Rect(position.x, Mathf.Floor(num6), position.width, num5); gUIStyle.Draw(position3, false, false, false, false); } Rect position4 = new Rect((a.x - pixelPos.x) * num3 + position.x, (a.y - pixelPos.y) * num5 + position.y, num3, num5); EyeDropper.styles.eyeDropperPickedPixel.Draw(position4, false, false, false, false); GL.sRGBWrite = false; }
public static void DrawPreview(Rect position) { if (Event.current.type != EventType.Repaint) { return; } if (EyeDropper.styles == null) { EyeDropper.styles = new EyeDropper.Styles(); } Texture2D texture2D = EyeDropper.get.m_Preview; int num = (int)Mathf.Ceil(position.width / 10f); int num2 = (int)Mathf.Ceil(position.height / 10f); if (texture2D == null) { texture2D = (EyeDropper.get.m_Preview = ColorPicker.MakeTexture(num, num2)); texture2D.filterMode = FilterMode.Point; } if (texture2D.width != num || texture2D.height != num2) { texture2D.Resize(num, num2); } Vector2 a = GUIUtility.GUIToScreenPoint(Event.current.mousePosition); Vector2 pixelPos = a - new Vector2((float)(num / 2), (float)(num2 / 2)); texture2D.SetPixels(InternalEditorUtility.ReadScreenPixel(pixelPos, num, num2), 0); texture2D.Apply(true); Graphics.DrawTexture(position, texture2D); float num3 = position.width / (float)num; GUIStyle gUIStyle = EyeDropper.styles.eyeDropperVerticalLine; for (float num4 = position.x; num4 < position.xMax; num4 += num3) { Rect position2 = new Rect(Mathf.Round(num4), position.y, num3, position.height); gUIStyle.Draw(position2, false, false, false, false); } float num5 = position.height / (float)num2; gUIStyle = EyeDropper.styles.eyeDropperHorizontalLine; for (float num6 = position.y; num6 < position.yMax; num6 += num5) { Rect position3 = new Rect(position.x, Mathf.Floor(num6), position.width, num5); gUIStyle.Draw(position3, false, false, false, false); } Rect position4 = new Rect((a.x - pixelPos.x) * num3 + position.x, (a.y - pixelPos.y) * num5 + position.y, num3, num5); EyeDropper.styles.eyeDropperPickedPixel.Draw(position4, false, false, false, false); }
public static void DrawPreview(Rect position) { if (Event.current.type != EventType.Repaint) return; if (EyeDropper.styles == null) EyeDropper.styles = new EyeDropper.Styles(); Texture2D texture2D = EyeDropper.get.m_Preview; int num1 = (int) Mathf.Ceil(position.width / 10f); int num2 = (int) Mathf.Ceil(position.height / 10f); if ((Object) texture2D == (Object) null) { EyeDropper.get.m_Preview = texture2D = ColorPicker.MakeTexture(num1, num2); texture2D.filterMode = UnityEngine.FilterMode.Point; } if (texture2D.width != num1 || texture2D.height != num2) texture2D.Resize(num1, num2); Vector2 screenPoint = GUIUtility.GUIToScreenPoint(Event.current.mousePosition); Vector2 pixelPos = screenPoint - new Vector2((float) (num1 / 2), (float) (num2 / 2)); texture2D.SetPixels(InternalEditorUtility.ReadScreenPixel(pixelPos, num1, num2), 0); texture2D.Apply(true); Graphics.DrawTexture(position, (Texture) texture2D); float width = position.width / (float) num1; GUIStyle dropperVerticalLine = EyeDropper.styles.eyeDropperVerticalLine; float x = position.x; while ((double) x < (double) position.xMax) { Rect position1 = new Rect(Mathf.Round(x), position.y, width, position.height); dropperVerticalLine.Draw(position1, false, false, false, false); x += width; } float height = position.height / (float) num2; GUIStyle dropperHorizontalLine = EyeDropper.styles.eyeDropperHorizontalLine; float y = position.y; while ((double) y < (double) position.yMax) { Rect position1 = new Rect(position.x, Mathf.Floor(y), position.width, height); dropperHorizontalLine.Draw(position1, false, false, false, false); y += height; } Rect position2 = new Rect((screenPoint.x - pixelPos.x) * width + position.x, (screenPoint.y - pixelPos.y) * height + position.y, width, height); EyeDropper.styles.eyeDropperPickedPixel.Draw(position2, false, false, false, false); }