// Using "Init" here so usage can avoid per-stroke heap activity. public void BaseInit(Stroke stroke, PointerScript pointer, CanvasScript canvas) { if (stroke.m_Type != Stroke.Type.NotCreated) { UnityEngine.Debug.LogWarningFormat("Unexpected: playback stroke type {0}", stroke.m_Type); stroke.Uncreate(); } m_pointer = pointer; m_stroke = stroke; m_nextControlPoint = 0; m_isDone = false; // We make the BeginLine call, even though the stroke time may be in the future. // Harmless with current brushes since no geometry is generated until UpdateLinePosition. // We can move code to Update() if this changes. m_stroke.m_Object = m_pointer.BeginLineFromMemory(m_stroke, canvas); m_stroke.m_Type = Stroke.Type.BrushStroke; if (m_stroke.m_Object == null) { if (!sm_BrushGuidWarnings.Contains(m_stroke.m_BrushGuid)) { OutputWindowScript.m_Instance.AddNewLine("Brush not found! Guid: " + m_stroke.m_BrushGuid); sm_BrushGuidWarnings.Add(m_stroke.m_BrushGuid); } m_isDone = true; } }
private void ApplyColorAndBrushToObject(Color color, Guid brushGuid) { m_TargetStroke.m_Color = ColorPickerUtils.ClampLuminance( color, BrushCatalog.m_Instance.GetBrush(brushGuid).m_ColorLuminanceMin); m_TargetStroke.m_BrushGuid = brushGuid; m_TargetStroke.InvalidateCopy(); m_TargetStroke.Uncreate(); m_TargetStroke.Recreate(); }
/// Restore stroke to its unrendered state, deleting underlying geometry. /// This is used by rewind functionality of ScenePlayback. /// TODO: Rather than destroying geometry for rewind, we should employ the hiding /// mechanism of the stroke erase / undo operations. public void UnrenderStrokeMemoryObject(Stroke stroke) { TiltMeterScript.m_Instance.AdjustMeter(stroke, up: false); stroke.Uncreate(); }