diff --git a/Runtime/CellularAutomaton/CellularAutomaton.cs b/Runtime/CellularAutomaton/CellularAutomaton.cs index a6a99199..ce9dc1f8 100644 --- a/Runtime/CellularAutomaton/CellularAutomaton.cs +++ b/Runtime/CellularAutomaton/CellularAutomaton.cs @@ -10,13 +10,22 @@ namespace ProceduralToolkit.CellularAutomata public class CellularAutomaton { [Serializable] - public class Config + public struct Config { - public int width = 128; - public int height = 128; - public Ruleset ruleset = Ruleset.life; - public float startNoise = 0.25f; - public bool aliveBorders = false; + public int width; + public int height; + public Ruleset ruleset; + public float startNoise; + public bool aliveBorders; + + public static Config life = new Config + { + width = 128, + height = 128, + ruleset = Ruleset.life, + startNoise = 0.25f, + aliveBorders = false, + }; } private bool[,] _cells; diff --git a/Samples/CellularAutomata/CellularAutomatonExample.cs b/Samples/CellularAutomata/CellularAutomatonExample.cs index 9dbec1c2..3a50caae 100644 --- a/Samples/CellularAutomata/CellularAutomatonExample.cs +++ b/Samples/CellularAutomata/CellularAutomatonExample.cs @@ -16,7 +16,7 @@ public class CellularAutomatonExample : ConfiguratorBase public ToggleGroup toggleGroup; public RawImage image; [Space] - public CellularAutomaton.Config config = new CellularAutomaton.Config(); + public CellularAutomaton.Config config = CellularAutomaton.Config.life; private enum RulesetName { @@ -117,11 +117,11 @@ private void DrawCells() { if (automaton.cells[x, y]) { - pixels[y*config.width + x] = aliveColor; + pixels.SetXY(x, y, config.width, aliveColor); } else { - pixels[y*config.width + x] = deadColor; + pixels.SetXY(x, y, config.width, deadColor); } } }