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; }