public void OnMouseDrag(RagePixelState state) { if (Event.current.button != 0 || !ActiveDrag) { return; } Vector2Int pixel = state.ScreenToPixel(Event.current.mousePosition, false); var lastPixel = _lastMousePixel.Value; Utility.DrawPixelLine(state.Sprite.texture, state.Brush, lastPixel, pixel); if (state.SpriteRenderer.drawMode == SpriteDrawMode.Tiled) { var texSize = new Vector2Int(state.Sprite.texture.width, state.Sprite.texture.height); var diff = pixel - lastPixel; var lastPos = new Vector2Int(lastPixel.x % texSize.x, lastPixel.y % texSize.y); var pos = lastPos + diff; var shift1 = new Vector2Int(0, 0); var shift2 = new Vector2Int(texSize.x, 0); var shift3 = new Vector2Int(0, texSize.y); var shift4 = new Vector2Int(texSize.x, texSize.y); Utility.DrawPixelLine(state.Sprite.texture, state.Brush, lastPos + shift1, pos + shift1); Utility.DrawPixelLine(state.Sprite.texture, state.Brush, lastPos + shift2, pos + shift2); Utility.DrawPixelLine(state.Sprite.texture, state.Brush, lastPos + shift3, pos + shift3); Utility.DrawPixelLine(state.Sprite.texture, state.Brush, lastPos + shift4, pos + shift4); } _lastMousePixel = pixel; }
public void OnMouseDrag(RagePixelState state) { if (Event.current.button != 0 || !activeDrag) { return; } IntVector2 pixel = state.ScreenToPixel(Event.current.mousePosition, false); Utility.DrawPixelLine(state.sprite.texture, state.brush, m_LastMousePixel.Value, pixel); m_LastMousePixel = pixel; }
public void OnMouseDown(RagePixelState state) { if (Event.current.button == 0) { IntVector2 pixel = state.ScreenToPixel(Event.current.mousePosition, false); Color oldColor = state.sprite.texture.GetPixel((int)pixel.x, (int)pixel.y); Texture2D texture = state.sprite.texture; Rect spriteRect = state.sprite.textureRect; FloodFill(oldColor, state.paintColor, texture, (int)pixel.x, (int)pixel.y, (int)spriteRect.xMin, (int)spriteRect.yMin, (int)spriteRect.xMax, (int)spriteRect.yMax); texture.Apply(); Event.current.Use(); } }
public void OnMouseDown(RagePixelState state) { if (Event.current.button != 0) { return; } IntVector2 pixel = state.ScreenToPixel(Event.current.mousePosition, false); IntVector2 minPixel = pixel - state.brush.m_BrushPivot; Utility.SetPixelsClamped(state.sprite.texture, minPixel, state.brush.m_Size, state.brush.m_Colors); state.sprite.texture.Apply(); m_LastMousePixel = pixel; state.Repaint(); Event.current.Use(); }
private IntVector2 GetMousePixel(RagePixelState state, bool clamp) { return(state.ScreenToPixel(Event.current.mousePosition, clamp)); }