예제 #1
0
    private void Paint()
    {
        Paintable[] paintables       = FindObjectsOfType <Paintable>();
        float       closestDistance  = float.MaxValue;
        Paintable   closestPaintable = null;

        foreach (Paintable paintable in paintables)
        {
            float dist = (paintable.transform.position - PaintTipPosition).sqrMagnitude;
            if (dist < closestDistance && dist < paintBrushRadius * paintBrushRadius)
            {
                closestDistance  = dist;
                closestPaintable = paintable;
            }
        }

        //paint the thingy
        if (closestPaintable)
        {
            closestPaintable.Paint(Color);
        }
    }