/// <summary> /// Adds the vertex to current stroke's vertices. /// </summary> /// <param name="v">V.</param> public void AddVertex(Vertex v) { // TODO: try catch exception that if v == null or could not add v to CurStroke if (CurStroke != null) { CurStroke.AddVertex(v); } }
/// <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 }