/// Like BeginLineFromMemory + EndLineFromMemory /// To help catch bugs in higher-level stroke code, it is considered /// an error unless the stroke is in state NotCreated. public void RecreateLineFromMemory(Stroke stroke) { if (stroke.m_Type != Stroke.Type.NotCreated) { throw new InvalidOperationException(); } if (BeginLineFromMemory(stroke, stroke.Canvas) == null) { // Unclear why it would have failed, but okay. // I guess we keep the old version? Debug.LogError("Unexpected error recreating line"); return; } UpdateLineFromStroke(stroke); // It's kind of warty that this needs to happen; brushes should probably track // the mesh-dirty state and flush it in Finalize(). // TODO: Check if this is still necessary now that QuadStripBrushStretchUV // flushes pending geometry changes in Finalize*Brush() m_CurrentLine.ApplyChangesToVisuals(); // Copy in new contents if (App.Config.m_UseBatchedBrushes && m_CurrentLine.m_bCanBatch) { var subset = m_CurrentLine.FinalizeBatchedBrush(); stroke.m_Type = Stroke.Type.BatchedBrushStroke; stroke.m_IntendedCanvas = null; Debug.Assert(stroke.m_Object == null); stroke.m_BatchSubset = subset; stroke.m_BatchSubset.m_Stroke = stroke; m_CurrentLine.DestroyMesh(); Destroy(m_CurrentLine.gameObject); } else { m_CurrentLine.FinalizeSolitaryBrush(); stroke.m_Type = Stroke.Type.BrushStroke; stroke.m_IntendedCanvas = null; Debug.Assert(stroke.m_BatchSubset == null); stroke.m_Object = m_CurrentLine.gameObject; stroke.m_Object.GetComponent <BaseBrushScript>().Stroke = stroke; } m_CurrentLine = null; }
void OnDestroy() { foreach (var child in m_children) { BaseBrushScript bbs = child.m_brush; bbs.DestroyMesh(); Destroy(bbs.gameObject); } }
public void DisablePreviewLine() { if (m_PreviewLine) { // TODO: Remove this (and other) calls to DestroyMesh() and do it inside OnDestroy() instead? m_PreviewLine.DestroyMesh(); Destroy(m_PreviewLine.gameObject); m_PreviewLine = null; } }