Hello everyone! Im currently trying to paint a texture, a bit of code and it works, but i have a problem, if i move my mouse too quickly, painting has gaps, how can i fix this? Thanks in advance!
Texture2D tex = GetComponent<Image>().sprite.texture;
RectTransform rect = GetComponent<RectTransform>();
Vector2 pos;
RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, Input.mousePosition, null, out pos);
pos = new Vector2(pos.x + rect.sizeDelta.x / 2, pos.y + rect.sizeDelta.y / 2);
for (int i = 0; i < brushSize; i++)
{
for (int j = 0; j < brushSize; j++)
{
tex.SetPixel(Mathf.FloorToInt(pos.x - 1 * brushSize / 2 + j), Mathf.FloorToInt(pos.y + 1 * brushSize / 2 - i), color);
}
}
tex.Apply();