Example #1
0
    void Brush(Vector2 p1, Vector2 p2)
    {
        if (p2 == Vector2.zero)
        {
            p2 = p1;
        }

        PaintTexture.Paint(p1, p2, brushRadius, brushColor, brushHadness, imageTexture, false);
        imageTexture.Apply();
    }
Example #2
0
    public void ErasePaint(Vector2 point1, Vector2 point2)
    {
        if (point2 == Vector2.zero)
        {
            point2 = point1;
        }

        PaintTexture.FreeSelection(point1, point2, (radius / objectScale), Color.red, (opacity / objectScale), imageTexture,
                                   newImage.sprite.texture, false);
        newImage.sprite.texture.Apply();
    }
Example #3
0
    void Brush(Vector2 p1, Vector2 p2)
    {
        if (wasEntered)
        {
            Debug.Log("BRUSH");
        }

        if (p2 == Vector2.zero)
        {
            p2 = p1;
        }

        PaintTexture.Paint(p1, p2, brushRadius, brushColor, brushHadness, imageTexture);
        imageTexture.Apply();
    }
Example #4
0
    public void OnPointerEnter(PointerEventData eventData)
    {
        if (eventData.pointerCurrentRaycast.gameObject != null)
        {
            Debug.Log("Enter " + eventData.pointerCurrentRaycast.gameObject.name);
        }

        if (isBrushDown)
        {
            if (pointerEventData.pointerCurrentRaycast.gameObject != null &&
                CheckTexture(pointerEventData.pointerCurrentRaycast.gameObject))
            {
                imagePosition = pointerEventData.pointerCurrentRaycast.gameObject.transform.position;
                brushStart    = PaintTexture.GetTextureCordinate(imagePosition, brushPosition, screenRatio, imageTexture, currentObject.transform.eulerAngles.z);
            }
        }
    }
Example #5
0
    void Update()
    {
        brush.transform.position = Input.mousePosition;

        if (isBrushDown)
        {
            PointerRaycast();

            if (currentObject != pointerEventData.pointerCurrentRaycast.gameObject)
            {
                if (pointerEventData.pointerCurrentRaycast.gameObject != null &&
                    CheckTexture(pointerEventData.pointerCurrentRaycast.gameObject))
                {
                    brushStart  = Vector2.zero;
                    brushEnd    = brushStart;
                    brushPolish = brushEnd;
                    PointerDown();
                }
                else
                {
                    return;
                }
            }

            brushPosition = pointerEventData.pointerCurrentRaycast.screenPosition;

            brushEnd = PaintTexture.GetTextureCordinate(imagePosition, brushPosition, screenRatio, imageTexture, currentObject.transform.eulerAngles.z);

            if (brushStart == Vector2.zero)
            {
                return;
            }

            Brush(brushEnd, brushPolish);

            brushPolish = brushEnd;
        }
    }
Example #6
0
 void PointerDown()
 {
     imagePosition = pointerEventData.pointerCurrentRaycast.gameObject.transform.position;
     brushStart    = PaintTexture.GetTextureCordinate(imagePosition, brushPosition, screenRatio, imageTexture, currentObject.transform.eulerAngles.z);
     isBrushDown   = true;
 }