Map Magic World Generator - a node based procedural and infinite game map tool

Hey Wright

I find a bug in 2018.3.6.
Lets say I have a graph and save it.
If I reopen Unity there is an error:

InvalidOperationException: EnsureRunningOnMainThread can only be called from the main thread
UnityEngine.Object.EnsureRunningOnMainThread () (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:153)
UnityEngine.Object.GetInstanceID () (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:73)
UnityEngine.Object.IsNativeObjectAlive (UnityEngine.Object o) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:182)
UnityEngine.Object.CompareBaseObjects (UnityEngine.Object lhs, UnityEngine.Object rhs) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:140)
UnityEngine.Object.op_Inequality (UnityEngine.Object x, UnityEngine.Object y) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:405)
MapMagic.CustomSerialization.ReadClass (System.Int32 slotNum, System.Collections.Generic.List1[T] classes, System.Collections.Generic.List1[T] objects, System.Collections.Generic.List1[T] floats, System.Collections.Generic.List1[T] references) (at Assets/MapMagic/Main/CustomSerialization.cs:409)
MapMagic.CustomSerialization.ReadClass (System.Int32 slotNum, System.Collections.Generic.List1[T] classes, System.Collections.Generic.List1[T] objects, System.Collections.Generic.List1[T] floats, System.Collections.Generic.List1[T] references) (at Assets/MapMagic/Main/CustomSerialization.cs:398)
MapMagic.GeneratorsAsset.OnAfterDeserialize () (at Assets/MapMagic/Main/GeneratorsAsset.cs:1148)

And the graph is disappeared. I have to redo the graph again.
It happens when I upgrade to 2018.3.6.

1 Like

I have the same issue.

Could you send me the graph on that stage when the error is about to appear on loading it? So I could load it and get this error too to debug it.
Ruonan, iddqd, probably I will need graphs from both of you just to make sure this issue has the same reason.

PM your the graph

2 Likes
EnsureRunningOnMainThread can only be called from the main thread

Wait, what?! :eyes:

Why should one check the main thread if it could be checked from the main thread only? Guess EnsureRunningOnMainThread has ‘return true’ inside :slight_smile:

BTW it’s Unity 2018.3.6 issue, in Unity 2018.3.3 everything works as expected.

I will make a project to reproduce this issue and send it to Unity since I’m pretty sure it shouldn’t work this way. For now here is a hack fix. Will submit it in a new version if Unity won’t fix this before.

1 Like

By the way, the new MM version (1.9.7) is available at the Asset Store:

  • It brings the new Textures Output for 2018.3 texture layers (they could be assigned as the assets)
  • Doesn’t require demo folder anymore.
5 Likes

Hey,
We are using Map Magic and we are really happy with it.

The thing is we want use a second Map Magic Terrain to have some kind of LOD setup with lower map resolution and no grass and trees/objects for a wide distance view.

Question 1:
Is there some settings for this in the Map magic Inspector?

Question 2:
If not how could we create a second map magic object and generate the low resolution terrain like we want via script?
We just have to get the coordinates of the Main Map and generate around this coordinates the Low resolution terrain, the transition does not need to be good because the player will never reach this low resolution terrain when the main map keep generating.
I already try it out but map magic does not allow to use multiple map magic objects in one scene also the question is how we stop the low resolution map generating automatically at the main camera so that it’s only visible in the background.

It’s not built-in, but you can do it. MapMagic uses threading via a singleton so you CANNOT use two at the same time. You can swap between two in runtime though just fine, that’s how I do it. Just make sure all the threads are finished in one before you turn it off, then turn the other one on. You can also specify chunks for it to draw instead of using the main camera, though it can be useful to leave the camera reference with a super high on/off distance so it doesn’t automatically disable the terrains. Or you can have it generate around specific objects and place the objects yourself to represent which terrains you want it to draw.

I have some workflow problems with MM and i think its the terrain update that causes them. What is the last Unity version without problems?

If you are using a limited terrain then it’s probably better generate the low-resolution chunks beforehand, and then use only one MapMagic fore details in runtime. Using low-res terrains will not take much space, and you will not have to switch between two MM objects.

I have to admit that using singleton isn’t a good practice in this case. MM2 avoids this disadvantage, though I had to redesign it greatly.

The most recent MM available at the Asset Store (v.1.9.7) was tested in Unity 2018.3.3.
If you are using a later version and have an EnsureRunningOnMainThread can only be called from the main thread issue take a look at [this fix]( https://discussions.unity.com/t/619852 page-77#post-4296724).
Feel free to email me any problems you encounter using MM.

1 Like

Thank you for the response i will try to create my system probably in way 1 because we are working with a infinite terrain.

I updated Map magic to 1.9.7 and found out that something strange happens with my grass textures.
Im currently at Unity Version 2019.1.b6, and i can’t downgrade because unity uses some other logic in it’s packages, how ever i get this bug:
4306528--387052--2019-03-11 13_56_23-Stone Reverie.jpg
4306528--387109--2019-03-11 15_46_04-Stone Reverie.png
It’s only happens when you explore the world and walk to a chunk terrain which was not pinned and generated in the editor before so only at runtime generation, the default pinned terrain works without problems, also it only happens in a Build version not in the editor.

Is there something i have to take care from the textures settings?

Usually it looks like this:
4306528--387055--2019-03-11 14_23_33-Unity 2019.1.0b6-.png

Thanks for your general help.

I create new scene and new Map Magic object.
And I want to create it to prefab, so drag Map Magic object to Project view.
But terrain is disappered.
Maybe warning “Terrain Asset Missing” in “Terrain 0,0” object under the Map Magic object is causing,
Is there any solution?
Map Magic Version is 1.9.7
Unity Version is 2018.3.0f2
Thanks!

I tried your fix but it didn’t work - I got an error about object not being a texture 2d. I also now installed 2018.3.8f1, but the error is still there.

Any eta for Vegetation Studio Pro support ?

2 Likes

Really hoping for VS Pro support/integration as well. It’s at the top of my wish list.

It would help a lot if you could run the same scene in a stable Unity version. I’m not talking about the whole project, but you can export the graph and create MM object with the same settings in 2018.3, so no of the game logic will be used.

BTW was it working fine with the older MM version?

It’s the standard behavior when you try to create a prefab of a terrain - any terrain, not only MM one. You’ve got to use TerrainData asset in case of a standard terrain, and MapMagic Data (graph) in case of MM.

Could you please email me the graph that causes the error?

It’s planned for v1.10, but I can look into it tomorrow. Hope it’s the matter of days, but I’m NOT promising that, it’s just a plan.
Will look into MicroSplat integration too.

6 Likes

Thanks @Wright ! I love MM and VS Pro… and it’s difficult to live without either of them in my project.

Thanks @Wright - MicroSplat integration would be amazing!

I tested different Unity versions, 2018.3 works, 2019.1.0b5 works, 2019.1.0b6 don’t works.
Probably they forget something or changed something in this version, it’s only effecting the Build Version and not the Editor.

In the demo scene build the bug behaves a little different, the grass texture is just not existing anymore in the new runtime generated chunk.
4311538--387817--2019-03-12 16_31_39-Stone Reverie.png

I don’t know i just made a general function test and then i notice it.

It seems Unity will not have any update on this bug soon. Already Patch the fix. Thanks a lot.

For now I am trying to integrate VS. I read a tutorial here: https://www.awesometech.no/index.php/set-up-with-map-magic-infinite-terrain/ . But this will break my workflow because I need all terrain to generate when game start. This method has to leave at least one terrain in scene.

I think Vegetation Studio Node in MM Graph will do this job, am I right? and I failed to find any tutorials about this node.

4314283--388288--upload_2019-3-13_17-35-9.png

It seems need drag VS package in the Packge. But I don’t know what should I put in the Prefab input.

Do you have any instruction on this node?