Example #1
0
    // Allows a line to be redrawn from history
    // Used by DrawingHistoryManager
    public void addReplayLineSegment(bool toContinue, float lineThickness, Vector3 position, Color color, Material primaryMaterial, Material secondaryMaterial, int layerNum)
    {
        if (toContinue == false)
        {
            // Start drawing a new line
            GameObject go = new GameObject();
            go.transform.position = position;
            go.transform.parent   = drawingRootSceneObject.transform;

            go.AddComponent <MeshFilter> ();
            go.AddComponent <MeshRenderer> ();
            currLine = go.AddComponent <GraphicsLineRenderer> ();
            currLine.SetLayerNum(layerNum);

            currLine.SetPrimaryMaterial(new Material(primaryMaterial));
            currLine.SetSecondaryMaterial(new Material(secondaryMaterial));
            currLine.SetWidth(lineThickness);
            currLine.SetColor(color);
        }
        else
        {
            // Continue drawing on the same line
            currLine.AddPoint(position);
        }
    }
Example #2
0
    } // _UpdateFeature()

    // Starts drawing a new line with the given point
    private void startNewLine(Vector3 firstPoint)
    {
        Debug.Log("startNewLine()");

        // Make sure we are in drawing mode
        if (!paintPanel.activeSelf && !snapToSurfaceBrushTipObject.activeSelf)
        {
            return;
        }

        // Create a new line object
        GameObject go = new GameObject();

        go.transform.position = firstPoint;
        go.transform.parent   = drawingRootSceneObject.transform;
        go.AddComponent <MeshFilter> ();
        go.AddComponent <MeshRenderer> ();

        int layerNum = GetComponent <PaintController>().GetActiveLayerNum();

        // Keep track of this line
        currLine = go.AddComponent <GraphicsLineRenderer>();
        currLine.SetLayerNum(layerNum);

        // Configure the color, etc. of the line
        currLine.SetPrimaryMaterial(new Material(lMat));
        if (lMat_texture)
        {
            currLine.SetSecondaryMaterial(new Material(lMat_texture));
        }
        currLine.SetWidth(paintLineThickness);
        currLine.SetColor(colorPicker.GetColor());


        // Keep track of the last point on the line
        prevPaintPoint = firstPoint;

        // Add to history and increment index
        Debug.Log("Adding History 1");
        int index = GetComponent <PaintController> ().drawingHistoryIndex;

        index++;

        Debug.Log("Adding History 2");
        paintBrushSceneObject.GetComponent <DrawingHistoryManager> ().addDrawingCommand(index, 0, firstPoint, currLine.GetColor(), paintLineThickness, lMat, lMat_texture, layerNum);

        Debug.Log("Adding History 3");
        GetComponent <PaintController>().drawingHistoryIndex = index;

        Debug.Log("Done Adding History");

        // Make sure the trail is off
        if (brushTipObject.activeSelf)
        {
            brushTipObject.GetComponent <TrailRenderer>().enabled = false;
        }
    }