private void Update() { if (Canvas == null) { return; } EditorCellHelper.SetAlive(); }
private void UpdateVisualisation() { if (Canvas == null) { Debug.LogWarning("Trying to draw Painter with null Canvas?"); return; } DrawSceneControls(); for (var i = 0; i < 5; ++i) { var scale = TRS.GetScale(); scale = new Vector3(scale.x * Rect.size.x, 0, scale.z * Rect.size.y); var rectPos = TRS.MultiplyPoint(Rect.min.x0z(PlaneOffset) + Vector3.up * i + Rect.size.x0z() / 2); HandleExtensions.DrawWireCube(rectPos, scale / 2, TRS.GetRotation(), Color.cyan.WithAlpha(1 - i / 5f)); } Handles.color = Color.white; if (CurrentBrush != null) { CurrentBrush.DrawGizmos(GridManager, _currentInputState, Rect, TRS); } var cellColor = Color.white; if (!_currentInputState.MouseBlocked && DoSceneGUIForHoverCell != null) { DoSceneGUIForHoverCell(GridManager.GetCell(_currentInputState.GridPosition)); } Handles.color = Color.magenta.WithAlpha(.2f); Handles.DrawDottedLine(_currentInputState.PlanePosition, _currentInputState.GridPosition, 1); _repaint |= Canvas.Dirty; EditorCellHelper.SetAlive(); // Tell the cell renderer that it should keep rendering EditorCellHelper.CellSize = GridManager.GetGridSize(); EditorCellHelper.TRS = TRS; if (_repaint) { EditorCellHelper.Clear(false); lock (Canvas) { Canvas.Dirty = false; var enumerator = Canvas.AllValues(); while (enumerator.MoveNext()) { cellColor = Ramp.Evaluate((enumerator.Current.Value - MinValue) / MaxValue); cellColor = cellColor.WithAlpha(cellColor.a * Opacity); if (TransmuteCellColor != null) { cellColor = TransmuteCellColor(enumerator.Current.Key, cellColor); } var cellPos = GridManager.GetCellCenter(enumerator.Current.Key).x0z(PlaneOffset); EditorCellHelper.AddCell(cellPos, cellColor); } } EditorCellHelper.Invalidate(); _repaint = false; } }