Initialising MM with a chosen seed at runtime
Created by: alastaira
As suggested on the forum, I currently start my scene with the MapMagic component disabled. From my scene manager script, I then set the world seed and enable the component as follows:
#!c#
mapMagic.seed = // seed loaded from savegame file;
mapMagic.enabled = true;
This works in v1.7. However, in the latest Master branch, this is leading to the following errors on entering playmode (only on every other time):
Thread Error: System.ArgumentException: An element with the same key already exists in the dictionary.
at System.Collections.Generic.Dictionary2[System.Type,MapMagic.Action
5[Plugins.CoordRect,MapMagic.Chunk+Results,MapMagic.GeneratorsAsset,MapMagic.Chunk+Size,Plugins.ThreadWorker]].Add (System.Type key, MapMagic.Action`5 value) [0x0007e] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:404
at MapMagic.GeneratorsAsset.Generate (CoordRect rect, MapMagic.Results results, Size terrainSize, Int32 seed, Plugins.ThreadWorker worker) [0x001fa] in C:\Users\alast\Projects\Unity\NOME\Assets\MapMagic\Main\GeneratorsAsset.cs:219
at MapMagic.Chunk.ThreadFn () [0x0004f] in C:\Users\alast\Projects\Unity\NOME\Assets\MapMagic\Main\Chunk.cs:189
at Plugins.ThreadWorker.ThreadFn () [0x00020] in C:\Users\alast\Projects\Unity\NOME\Assets\MapMagic\PluginTools\ThreadWorker.cs:501
UnityEngine.Debug:LogError(Object)
Plugins.ThreadWorker:ThreadFn() (at Assets/MapMagic/PluginTools/ThreadWorker.cs:525)
and then (presumably because the chunk is not generated):
ArgumentException: Trying to access out-of-bounds terrain height information. Plugins.WeldTerrains.WeldToPrevZ (System.Single[,]& heights, UnityEngine.Terrain neig, Int32 margin) (at Assets/MapMagic/PluginTools/WeldTerrains.cs:55) MapMagic.HeightOutput+c__Iterator2.MoveNext () (at Assets/MapMagic/Generators/OutputGenerators.cs:241) MapMagic.GeneratorsAsset+c__Iterator2.MoveNext () (at Assets/MapMagic/Main/GeneratorsAsset.cs:279) MapMagic.Chunk+c__Iterator0.MoveNext () (at Assets/MapMagic/Main/Chunk.cs:199) Plugins.ThreadWorker.CoroutineFn () (at Assets/MapMagic/PluginTools/ThreadWorker.cs:572) Plugins.ThreadWorker.UpdateApply () (at Assets/MapMagic/PluginTools/ThreadWorker.cs:164) Plugins.ThreadWorker.Refresh () (at Assets/MapMagic/PluginTools/ThreadWorker.cs:137) MapMagic.MapMagic.Update () (at Assets/MapMagic/MapMagic.cs:264)
I see there is now a "Change seed on playmode start" checkbox, but that just seems to randomise the seed - how should I now set a specific seed at scene start in runtime through script?