Пример #1
0
    void PaintBrush()
    {
        if (Input.GetMouseButtonDown(0))
        {
            layerCount++;
            activeLine = Instantiate(brushPrefabs[0], transform).GetComponent <PaintBrush>();
            activeLine.GetComponent <LineRenderer>().widthMultiplier       = brushSize;
            activeLine.GetComponent <EdgeCollider2D>().edgeRadius          = brushSize / 2;
            activeLine.GetComponent <LineRenderer>().material              = brushMat;
            activeLine.GetComponent <LineRenderer>().material.renderQueue += layerCount;
            activeLine.gameObject.layer = LayerMask.NameToLayer("Ground");
        }

        if (Input.GetMouseButtonUp(0))
        {
            activeLine = null;
        }

        if (activeLine != null)
        {
            Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            activeLine.UpdateLine(mousePos);
        }
    }