CreateBrush() public static method

public static CreateBrush ( Stroke, stroke, string name, object>.Dictionary options ) : IBrush
stroke Stroke,
name string
options object>.Dictionary
return IBrush
Ejemplo n.º 1
0
 public void StartNewStroke()
 {
     if (CurrentStroke == null)
     {
         CurrentStroke = new Stroke();
         strokes.Add(CurrentStroke);
         curIndex            = strokes.Count - 1;
         CurrentStroke.Brush = BrushManager.CreateBrush(CurrentStroke, SelectedBrush, null);
         CurrentStroke.Brush.SetOptions(options[CurrentStroke.Brush.BrushName]);
     }
 }
Ejemplo n.º 2
0
    /// <summary>
    /// Starts the new stroke.
    /// </summary>
    public void startNewStroke(GameObject painting, GameObject brushCursor)
    {
        if (CurStroke == null)
        {
            // ################# using prefab to create stroke game object #################

            // Make sure current stroke is empty and Create a new stroke according to selected brush type
            // GameObject.Instantiate(Object original, Vector3 position, Quaternion rotation);
            // original: An existing object that you want to make a copy of.
            // position: Position for the new object (default Vector3.zero).
            // rotation: Orientation of the new object (default Quaternion.identity).
            GameObject newStroke = (GameObject)Instantiate(BrushManager.getPrefab(SelectedBrush), brushCursor.transform.position, brushCursor.transform.rotation);

            // #############################################################################
            // Rename new stroke gameobject in the scene
            string name = "Stroke_" + strokes.Count.ToString();
            newStroke.name = name;

            // Make new stroke be a child of painting object
            newStroke.transform.SetParent(painting.transform, false);

            // Scale new stroke size according whole project scale
            // TODO: whole project scale needed to be redesigned
            newStroke.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);


            // get newStroke's stroke object from script component
            CurStroke = newStroke.GetComponent <Stroke> ();
            CurStroke.Initialize();

            // Add newStroke to stroke list
            strokes.Add(CurStroke);
            curStrokeIndex = strokes.Count - 1;

            // Create brush scriptableobject related to current stroke
            CurStroke.Brush = BrushManager.CreateBrush(CurStroke, SelectedBrush, options [SelectedBrush]);

            // because in above line, brush of curStroke haven't been created, so pass null, to CreateBrush
            // Set options after CurStroke.Brush been created
            CurStroke.Brush.SetOptions(options [CurStroke.Brush.BrushName]);
        }
        // TODO: if the CurStroke is not empty
    }