Ejemplo n.º 1
0
        public static GUIPainter DrawPainter(GUIPainter painter, Vector2 samplePosition, Vector2 pickerPosition, Color color, Action <Color> onColorChanged, Action onSampleClick)
        {
            if (painter == null)
            {
                painter = new GUIPainter()
                {
                    showPicker     = false,
                    samplePosition = samplePosition,
                    pickerPosition = pickerPosition,
                    clickingH      = false,
                    clickingSV     = false,
                    onColorChanged = onColorChanged
                };
                float h, s, v;
                Color.RGBToHSV(color, out h, out s, out v);
                painter.H = h;
                painter.S = s;
                painter.V = v;
                painter.GenerateSVPicker();
            }

            /* float nh, ns, nv;
             * Color.RGBToHSV(color, out nh, out ns, out nv);
             * painter.H = nh;
             * painter.S = ns;
             * painter.V = nv; */
            // painter.onColorChanged = onColorChanged;
            GUI.color = new Color(color.r, color.g, color.b);
            if (GUI.Button(new Rect(samplePosition, new Vector2(26, 20)), "████"))
            {
                ProceduralObjectsLogic.PlaySound();
                if (painter.showPicker == false)
                {
                    float nh, ns, nv;
                    Color.RGBToHSV(color, out nh, out ns, out nv);
                    painter.H = nh;
                    painter.S = ns;
                    painter.V = nv;
                    painter.GenerateSVPicker();
                }
                painter.showPicker = !painter.showPicker;
                onSampleClick.Invoke();
            }
            GUI.color = Color.white;
            if (painter.showPicker)
            {
                DrawPicker(painter, color);
            }
            painter.samplePosition = samplePosition;
            painter.pickerPosition = pickerPosition;
            return(painter);
        }
Ejemplo n.º 2
0
 public static void UpdatePainter(GUIPainter p, Action onClosePicker)
 {
     if (p == null)
     {
         return;
     }
     if (Input.GetMouseButtonDown(1))
     {
         onClosePicker.Invoke();
         return;
     }
     if (p.showPicker)
     {
         if (Input.GetMouseButtonDown(0))
         {
             Vector2 guiMousePos = GUIUtils.MousePos;
             if (!p.pickerRect.Contains(guiMousePos) && !p.sampleRect.Contains(guiMousePos))
             {
                 p.clickingSV = false;
                 p.clickingH  = false;
                 onClosePicker.Invoke();
                 return;
             }
             if (new Rect(p.pickerPosition + new Vector2(5, 5), new Vector2(180, 180)).Contains(guiMousePos))
             {
                 p.clickingSV = true;
                 ProceduralObjectsLogic.PlaySound(3);
             }
             else if (new Rect(p.pickerPosition + new Vector2(195, 5), new Vector2(25, 180)).Contains(guiMousePos))
             {
                 p.clickingH = true;
                 ProceduralObjectsLogic.PlaySound(3);
             }
         }
     }
     if (p.clickingSV)
     {
         p.PickupSVApply();
     }
     else if (p.clickingH)
     {
         p.PickupHueApply();
     }
     if (Input.GetMouseButtonUp(0))
     {
         p.clickingH  = false;
         p.clickingSV = false;
     }
 }
Ejemplo n.º 3
0
        public static void DrawPicker(GUIPainter painter, Color color)
        {
            GUI.BeginGroup(painter.pickerRect);
            GUI.Box(new Rect(0, 0, 225, 190), string.Empty);
            GUI.DrawTexture(new Rect(5, 5, 180, 180), painter.SVPicker);
            GUI.DrawTexture(new Rect(180f * painter.S - 2, 178 - painter.V * 180f, 14, 14), ProceduralObjectsMod.Icons[10]);
            GUI.DrawTexture(new Rect(195, 5, 25, 180), HuePicker);
            GUI.DrawTexture(new Rect(195, 183 - painter.H * 180f, 25, 4), ProceduralObjectsMod.Icons[11]);

            if (GUI.Button(new Rect(0, 192, 85, 22), LocalizationManager.instance.current["colorPicker_store"]))
            {
                ProceduralObjectsLogic.PlaySound();
                RegisterColor(color);
            }
            GUI.color = SavedColors[0];
            if (GUI.Button(new Rect(new Rect(87, 192, 26, 20)), "████"))
            {
                painter.SetColor(SavedColors[0]);
            }
            GUI.color = SavedColors[1];
            if (GUI.Button(new Rect(new Rect(115, 192, 26, 20)), "████"))
            {
                painter.SetColor(SavedColors[1]);
            }
            GUI.color = SavedColors[2];
            if (GUI.Button(new Rect(new Rect(143, 192, 26, 20)), "████"))
            {
                painter.SetColor(SavedColors[2]);
            }
            GUI.color = SavedColors[3];
            if (GUI.Button(new Rect(new Rect(171, 192, 26, 20)), "████"))
            {
                painter.SetColor(SavedColors[3]);
            }
            GUI.color = SavedColors[4];
            if (GUI.Button(new Rect(new Rect(199, 192, 26, 20)), "████"))
            {
                painter.SetColor(SavedColors[4]);
            }
            GUI.color = Color.white;
            GUI.EndGroup();
        }