Exemple #1
0
        void FilledRectangle(Event e)
        {
            Vector2 pixelCoord = EditorTextureUtilities.CalculatePixel(e.mousePosition, body.GetRect().position, bodyTextureRect, cellWidth, cellHeight);

            helper = toDrawTexture;
            if (e.control)
            {
                if (e.type == EventType.MouseDown)
                {
                    downMousePosition = EditorTextureUtilities.CalculatePixel(e.mousePosition, body.GetRect().position, bodyTextureRect, cellWidth, cellHeight);
                    if (e.button == 0)
                    {
                        CalculateFilledRectangle(helper, downMousePosition, pixelCoord, new Color(leftMoseButtonColor.r, leftMoseButtonColor.g, leftMoseButtonColor.b, 0.5f));
                    }
                    if (e.button == 1)
                    {
                        CalculateFilledRectangle(helper, downMousePosition, pixelCoord, new Color(1 - leftMoseButtonColor.r, 1 - leftMoseButtonColor.g, 1 - leftMoseButtonColor.b, 0.5f));
                    }
                }
                if (e.type == EventType.MouseDrag)
                {
                    if (e.button == 0)
                    {
                        CalculateFilledRectangle(helper, downMousePosition, pixelCoord, new Color(leftMoseButtonColor.r, leftMoseButtonColor.g, leftMoseButtonColor.b, 0.5f));
                    }
                    if (e.button == 1)
                    {
                        CalculateFilledRectangle(helper, downMousePosition, pixelCoord, new Color(1 - leftMoseButtonColor.r, 1 - leftMoseButtonColor.g, 1 - leftMoseButtonColor.b, 0.5f));
                    }
                }
                if (e.type == EventType.MouseUp)
                {
                    upMousePosition = EditorTextureUtilities.CalculatePixel(e.mousePosition, body.GetRect().position, bodyTextureRect, cellWidth, cellHeight);
                    if (e.button == 0)
                    {
                        CalculateFilledRectangle(textureInfo, downMousePosition, upMousePosition, leftMoseButtonColor);
                    }
                    if (e.button == 1)
                    {
                        CalculateFilledRectangle(textureInfo, downMousePosition, upMousePosition, rightMouseButtonColor);
                    }
                    EditorTextureUtilities.ClearTexture(helper, true);
                }
            }
            else
            {
                return;
            }
        }
Exemple #2
0
 void PaintErase(Event e)
 {
     helper = toDrawTexture;
     if (body.GetRect().Contains(e.mousePosition))
     {
         mouseToPixel = EditorTextureUtilities.CalculatePixel(e.mousePosition, body.GetRect().position, bodyTextureRect, cellWidth, cellHeight);
         if (mouseToPixel.x < 0 || mouseToPixel.y < 0 || mouseToPixel.x >= toDrawTexture.width || mouseToPixel.y >= toDrawTexture.height)
         {
             needsRepaint = true;
             if (helper != null)
             {
                 EditorTextureUtilities.ClearTexture(helper, true);
             }
             return;
         }
         if ((e.type == EventType.MouseDrag || e.type == EventType.MouseDown))
         {
             if (e.button == 0)
             {
                 textureInfo.SetPixel((int)mouseToPixel.x, toDrawTexture.height - (int)mouseToPixel.y - 1, leftMoseButtonColor);
             }
             if (e.button == 1)
             {
                 textureInfo.SetPixel((int)mouseToPixel.x, toDrawTexture.height - (int)mouseToPixel.y - 1, rightMouseButtonColor);
             }
         }
         else
         {
             helper.SetPixel((int)mouseToPixel.x, toDrawTexture.height - (int)mouseToPixel.y - 1, new Color(leftMoseButtonColor.r, leftMoseButtonColor.g, leftMoseButtonColor.b, 0.5f));
             helper.Apply();
         }
     }
     else
     {
         mouseToPixel = new Vector2(0, 0);
         if (helper != null)
         {
             EditorTextureUtilities.ClearTexture(helper, true);
         }
     }
     needsRepaint = true;
 }