Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We are updating our Terms of Service for all Unity subscription plans, effective October 13, 2022, to create a more streamlined, user-friendly set of terms. Please review them here: unity.com/legal/terms-of-service.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice
  4. Join us on Thursday, September 29, for a day with Unity's SRP teams here on the forum or on Reddit, and discuss topics around URP, HDRP, and the Scriptable Render Pipeline in general.
    Dismiss Notice

[ON SALE - HUMBLE BUNDLE] Map Graph – Node-based Random Map Generation

Discussion in 'Assets and Asset Store' started by InsaneScatterbrain, Aug 3, 2020.

  1. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    Yes, you can use tilemap sets for this. There's a page in the manual about it here: https://mapgraph.insanescatterbrain.com/manual/tilemap_sets.html

    If you want to look at an example, you can take a look at the "Village" example in the sample project.
     
    w409544041 likes this.
  2. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    Map Graph v1.17.2 is now available.

    Changes:
    • Renaming a graph now reloads the editors to reflect the new names of subgraphs.

    • Fixed several issues that would throw exceptions when using a 0x0 or 1x1 texture size.

    • Changed a line of code that required a C# version higher than 7.3, so that Map Graph is now compatible again with C# 7.3.

    • Added missing initializations for ports on newer nodes to avoid unnecessary warnings about this.

    Check out the complete changelog here.
     
  3. Also

    Also

    Joined:
    Jul 17, 2013
    Posts:
    16
    Hello!

    I bought this asset when it was released, but I didn't really start to use it until a couple months ago.

    I'm working on a game with procedural level generation, and I had the generation algorithms implemented in plain C#, without using 3rd party libraries. I like the idea behind Map Graph so I migrated most of my codebase to create new custom nodes to use with Map Graph.

    I have almost everything migrated to the Map Graph API but there's one thing in particular that I don't think is possible doing on a graph right now.
    My world generator has to generate a random number of buildings, caves and other different structures. I have those other generators defined on separate graphs and right now I'm creating and running those subgraphs when the world generator graph is done, using something like
    worldGenerator.OnProcessed += OnWorldGenerated;
    .

    Then, inside the OnWorldGenerated I have something like

    Code (CSharp):
    1.  
    2. private void OnWorldGenerated(IReadOnlyDictionary<string, object> outputParameters) {
    3.     var pois = outputParameters["Points Of Interest"] as List<PointOfInterestInstanceData>;
    4.  
    5.     ...
    6.  
    7.     // Generate points of interest
    8.  
    9.     if (pois != null) {
    10.         foreach (var pointOfInterest in pois) {
    11.             // Instantiate new ScriptGraphRunners and run them
    12.         }
    13.     }
    14.     ...
    15. }
    It would be much cleaner if I can put this foreach loop inside the main graph itself: a for node linked to a custom "Instantiate new ScriptGraphRunners and run them" node.

    Is it possible to make this implementation cleaner right now. If not, would it be possible to introduce a "for loop" node? I think it would help to create much more complex graphs.

    Thank you very much!
     
  4. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    Hi Also,

    You could try and implement the generation of those buildings and caves inside the main graph (or a subgraph ran from the main graph), without having to run those from a different graph runner, separately. Basically, restructure your graph so a loop is not required. For me, at least, whenever I seem to need a loop, I can usually work around that by restructuring the way I'm generating the map.

    In some more complex situations that may not really be viable though. Without knowing what your graphs look like, it's hard to say if that's viable, or if you're better off with the solution you're suggesting, which is the only way to run graphs in a loop. For now, at least.

    Adding logical nodes such as for loops and if/else nodes, is something I plan to explore in the near future, but I think that might take some time to implement. So, I can't really make any promises on if and when that will be implemented. I will keep you updated here on those plans though. :)
     
    Last edited: Jul 27, 2022
  5. Also

    Also

    Joined:
    Jul 17, 2013
    Posts:
    16
    Good to know that you have it on your roadmap :)

    The thing is that the number of "secondary graphs" is random, so I don't think I can do it inside the main graph (as it would require to manually add the N number of nodes of the secondary graphs beforehand).

    Another thing which is what actually made me hold on using Map Graph until now is that it's constantly freezing my editor from time to time getting the popup "Map Graph is applying changes. This might take a while" or directly freezing Unity without notice. It usually happens when modifying a graph or when finishing "Play Mode". It happened to me a while back (around a year and a half) on a previous project and it's happening on this new one too. Is this a known issue?

    Thank you very much!
     
  6. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    No, I was not aware of this issue. That sounds very annoying. Sorry for the inconvenience!

    That popup should only show up when updating to a new version of Map Graph and only if Map Graph needs to make some changes to any existing assets to keep them compatible with that newer version.

    I'm currently on vacation, but I'll take a look at this as soon as I get back next week.

    Could you tell me what version of Unity and what version of Map Graph you're currently using?

    Are there any warning/error messages in the console window that might be related to this issue?

    Can you maybe describe the steps I could take to reproduce this issue in a new project?
     
  7. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    I've spent some time trying to debug Map Graph's updater system. I did fix a bug, but to be honest, I doubt it's the one that's plaguing you. The fix will be in the next update, but if you want to try it now, I've added a patch .unitypackage file to this post. Make sure you backup your project before you import it, just to be on the safe side.

    If this doesn't solve your issue, I will probably need some more information before I can reproduce and solve the issue. Any of the questions, I've put in the previous post, that you can answer would be helpful. :)
     

    Attached Files:

  8. Also

    Also

    Joined:
    Jul 17, 2013
    Posts:
    16
    Thanks, I'll take a look and try to put together the steps to reproduce the issue in a new project just in case it's still failing. Sorry, I've been swamped with my job for the past few days and I didn't have time for this project.

    Thank you!
     
    InsaneScatterbrain likes this.
  9. Also

    Also

    Joined:
    Jul 17, 2013
    Posts:
    16
    Hi :)

    I had the chance to setup and empty project, only with Map Graph and a custom script (similar to the example that I mentioned before) reproducing the issue that I mentioned, making Unity freeze as soon as I click play on my sample scene.

    Is there any way I can send you this test project to have a look?

    Thank you very much!
     
  10. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    Thanks for getting back to me. If you can try to mail it to support@insanescatterbrain.com, I'll take a look at it as soon as I can. :)

    If you prefer, you can also send me a DM here on the forums. I believe you can attach a file to it.
     
  11. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    Map Graph v1.18 is now available.

    Please note that the minimum required Unity version is now changed from 2019.3 to 2019.4 on the Asset Store page. This is due to a new Asset Store requirement, where asset updates need to be for 2019.4 or higher. Map Graph itself should still work perfectly fine with 2019.3.

    Changes:
    • Added following subgraphs:
      • Areas/Connect Rectangles (Centroid)
      • Base/Connected BSP Rooms
      • Base/Connected Caves (Cellular Automata)
      • Base/Connected Equal Rooms
    • Added ability to create custom preview behaviours for subgraphs.

    • Added custom preview behaviour for the Random BSP Rooms subgraph.

    • Added the Vector2Int To Vector2 node.

    • Moved the Random BSP Rooms node to the BSP category.

    • Renamed "Node Comment" option to "Add Comment".

    • Attempting to copy input/output nodes from one graph to another no longer throws an exception and triggers a warning instead.

    • Attempting to copy a connection between two nodes where one of the nodes won't exist in the destination graph will be skipped instead of throwing an exception.

    • The updater system no longer tries to update Map Graph assets when entering playmode.

    • Fixed bug that could cause the updater system to throw a null reference exception.

    • Fixed issue where attempting to add a comment to a node wouldn't work in certain versions of Unity.

    • Fixed issue where creating a new constant node with a text input wouldn't autofocus that textfield in certain versions of Unity.

    • Fixed explicit in port types on the Multiply (Vector2) node.

    • Sample Project: Added more comments and groups to some of the examples so that they're easier to read and understand.

    Check out the complete changelog here.
     
  12. MoFaShi

    MoFaShi

    Joined:
    Oct 25, 2015
    Posts:
    42
    hi, does this asset can make a world map that contains different styles like grass, lava, ice, etc. in a single map?
     
  13. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    There's not really a limit to the type of styles you can place on a single map. The sample project contains maps that have water, grass, trees, mountains, buildings, etc. There's no reason you wouldn't be able to add other stuff, like you're mentioning.

    There might be some limit to how you want to place them though. So it really depends on what you need your maps to look like, other than the style you're using. If you're running into trouble with that though, just let me know and we'll figure out a solution. :)
     
  14. Also

    Also

    Joined:
    Jul 17, 2013
    Posts:
    16
    Hey just wanted ti post an update about my previously reported issues.

    The demo project that I made to replicate the issue was freezing, but it was my fault and not MapGraph's fault.

    For the real project, I had the issue that MapGraph was constantly updating the graphs and opening scenes in the background when entering/leaving play mode due to how the updater worker previously. Being my project quite big, this resulted in super long wait times every time I wanted to playtest my project, and sometimes I had to force quit Unity because it simply takes too long.

    Happy to report that I've been using this last version since Friday and now everything seems to be running smoothly :)
     
    InsaneScatterbrain likes this.
  15. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    Glad to hear that the latest update solves your issue! :)

    Please let me know if you run into any other issues.
     
  16. sourfish

    sourfish

    Joined:
    Aug 22, 2022
    Posts:
    9
    My English is not good, so although I have seen all the discussions in the forum, I may have missed some information. I want to ask whether these needs can be realized:

    1. Every time a player starts a game, it is a random map, but the randomness of the map is controllable. For example, some areas are made in unity, and these areas can appear anywhere on the map, or I hope it can only be generated in a fixed area. Because I don't want the elements of the whole map to be random, I need some predefined areas for players to explore and trigger plot events.

    2. To obtain the active areas (areas where players and monsters can move) on the randomly generated map, I need to place some things in these areas, such as biological communities, monster attack points, task NPCs or items. I'm not sure how to achieve this, because they occupy different map spaces. How can I reasonably and controllably place them with C #.

    3. Once a map is generated in a game, can its data be saved, including other objects added by the script? Is there an API that provides such a function? Suppose a game has random maps of multiple landforms, and players can return to the previous map after arriving at the new map. I don't want it to be randomly generated again, but it is only generated once in this game.

    Sorry to ask so many questions at one time, but this is the map content I want to achieve in the game.
     
  17. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    You can create your own predefined parts. There's an example of that here in the sample project: https://insane-scatterbrain.itch.io/map-graph-demo-project

    The "Village" example uses this. The land, forest, crops, fences and roads are generated. The buildings and such are predefined and randomly placed within the level.

    If you want to limit the placement of those predefined pieces to certain areas, you can do so in by creating using masks. How to do this, is explained in the tutorials.

    There are at least two ways you could do this.

    1. You can place these areas in the world using Map Graph. (For example, the "Roguelike" examples in the sample project do this for the player starting point, the exit and enemies.)

    2. You can extract the active area and pass it as an output parameter so you can use that data outside of Map Graph. There is an OnProcessed event that you can hook into and get the values for the output parameters in your own C# scripts.

    There's no built-in solution to save/load maps and there are currently no plans to implement that feature. The reason being, that there are already a number of solutions to save/load game objects and since Map Graph simply generates game objects and/or tilemaps, it should work with any solution that supports saving those.

    Nothing is set in stone though. If it turns out that the need for a built-in solution is great, I could probably be persuaded to implement a basic save/load feature. :)

    Not at all! If you have any other questions, please don't hesitate to ask. :)
     
  18. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    Map Graph is a part of Unity's Art Humble Bundle! So now is the best time to get Map Graph (and other awesome assets!) for a very low price! :)
     
  19. sourfish

    sourfish

    Joined:
    Aug 22, 2022
    Posts:
    9
    Haha, I found this tool from the art humble bundle. Originally, I was puzzled by random maps, which is a very important part of the game I want to make. This is really a great tool. I have noticed that it is constantly updated.

    Thank you very much for your answer. Your enthusiasm gives me confidence to complete this part of the map. Regarding the third question last time, do you mean that I should use tools like easy save to complete the map saving function, or is there another recommended scheme. In fact, I'm still a novice in unity game development. Smile^_^
     
    InsaneScatterbrain likes this.
  20. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    Yes, that's what I meant. :)

    To be honest, I haven't had the need for saving/loading maps myself, so I don't have much experience with that yet. But assets like Easy Save tend to make it pretty easy to save/load game objects and such.

    I'll see about messing around with it a bit myself and see if it's actually as easy as I hope it is. Otherwise, I'll reconsider my position and will try to implement a basic save/load system. ;)
     
  21. sourfish

    sourfish

    Joined:
    Aug 22, 2022
    Posts:
    9
    That's great. If you find the best way to save and load, please add it to the help document. I'm also unfamiliar with this mechanism. :)
     
    InsaneScatterbrain likes this.
  22. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    I've been messing around a bit with some methods for saving and loading maps, but I'm not happy with the amount of effort it took me to do some basic saving and loading.

    As a result, I've been working on a basic saving and loading system, that will be included in the next update. It will be limited to saving and loading of texture data. So no saving of things you might add to the world separately from Map Graph. In those cases, you would need to use another solution that's specifically designed for that purpose.
     
  23. Tom-Kazansky

    Tom-Kazansky

    Joined:
    Mar 9, 2015
    Posts:
    38
    Hi, I just grabbed Map Graph (from Unity's Art Humble Bundle)
    this is a great tool, it would save me and my team's GD tons of time :D
    ---
    I'm currently on "Using prefabs instead of tilemaps" tutorial,
    but my prefab is like... 5 times bigger than normal (a standard "Cube"), is there a way I can increase the gap/offset between generated object? right now each object is 1 unit away from each other, I would like to increase this to 5.
    (if this is somewhat difficult, I can scale down the prefab instead)


    I generated a map with rooms using BPS tree, I want to add "walls" around the paths and rooms, so I use "Draw Outline" with "Walls" prefab as color. It works though my wall's orientation is not quite right (please see attached image), is there anyway I can rotate the walls to face the path/room?
     

    Attached Files:

  24. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    Yes, you can set the spacing between each object by setting the "Width" and "Height" on the prefab set. By default these are set to 1, but if you set those both to 5, it should solve your issue.

    Where you can find this option is shown here: https://mapgraph.insanescatterbrain.com/manual/using_prefabs_instead_of_tilemaps.html#prefab-sets

    Map Graph can't really know the relation between your wall and floor placement, so it can't automatically rotate the walls to match (or place multiple walls, in case of corners). You can solve this in two ways:

    1. The easiest way is to simply make the wall tile prefabs so that they'll fit no matter which side of the floor they're placed on. For example, instead of having a single wall, you can place a wall on each side. That way it should look good anywhere you place it.

    2. Instead of having one "Wall" prefab type, split it into "Left Wall", "Top Wall", etc, and use a Draw Outline for each using the Width Left, Width Right, etc. ports to draw the correct wall type on the correct sides. You can deal with corners by assigning a different parent object to each wall type, so they don't overwrite each other (using Texture To Child GameObjects nodes). Or you can get the corner points using a Corner Points node and create

    I usually prefer the first solution, if possible. It's easier to implement and you have less edge cases to deal with such as corners. :)

    Does this answer your questions?
     
    Last edited: Sep 14, 2022
    Tom-Kazansky likes this.
  25. Tom-Kazansky

    Tom-Kazansky

    Joined:
    Mar 9, 2015
    Posts:
    38
    oh, thank you,
    I missed that width/height settings :D

    I will consider both solutions, and, yes, the first one is easier to implement.

    EDIT: I decided to go with solution #2, and here is the result:
    gen-ed map.png
     
    Last edited: Sep 15, 2022
    InsaneScatterbrain likes this.
  26. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    Looks good! Glad you got it resolved. :)

    If there's anything else I can help with, just let me know.
     
  27. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
  28. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    A new version with a basic save/load system has just been released. :)
     
  29. sourfish

    sourfish

    Joined:
    Aug 22, 2022
    Posts:
    9
    Your response speed is really fast. I will study this new function carefully.
     
    InsaneScatterbrain likes this.
  30. Tom-Kazansky

    Tom-Kazansky

    Joined:
    Mar 9, 2015
    Posts:
    38
    Hi,
    I'm in the process of creating a new graph, it is used to generate playing stage for tower defense game, which include 1 or 2 "rooms" and some roads.

    When I run the graph, sometimes I encountered this error: (this is shortened version)
    Code (CSharp):
    1. ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    2. Parameter name: index
    3. System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    4. System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <695d1cc93cca45069c528c15c9fdd749>:0)
    5. System.Collections.Generic.List`1[T].set_Item (System.Int32 index, T value) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    6. InsaneScatterbrain.MapGraph.TextureData.SetColor (System.Int32 index, UnityEngine.Color32 color) (at Assets/Plugins/InsaneScatterbrain/MapGraph/DataStructures/TextureData.cs:85)
    Code (CSharp):
    1. KeyNotFoundException: The given key was not present in the dictionary.
    2. System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    3. InsaneScatterbrain.ScriptGraph.Editor.ScriptGraphView.FrameNode (InsaneScatterbrain.ScriptGraph.IScriptNode node) (at Assets/Plugins/InsaneScatterbrain/ScriptGraph.Editor/ScriptGraphView.cs:968)

    I attached the full error log below.

    if you think these error logs are not enough to figure out what's wrong, I will try to upload my graph, it's a bit big so I don't know how to capture it (may be I must screenshot separate parts and combine them)
     

    Attached Files:

  31. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    This exception occurs when a Draw Points node tries to draw a point that doesn't actually exist in the texture. For example, say you have a 10x10 texture, if it then tries to draw at a point where x > 9 or y > 9 (the coordinates start at 0, so a 10x10 would have a valid value range from 0 through 9 for both x and y), this error will occur.

    So my guess would be that for that Draw Points node, either the texture needs to be bigger or the points are generated using bounds that are too large.

    I hope this helps you track down the issue.

    If it doesn't, I might need (a part of) your graph to help you further. If you need to make multiple screenshots, don't worry about combining them. If it's not too messy, I'll probably be able to figure out which part goes where easily enough. :)
     
  32. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    Map Graph v1.19.1 is now available.

    Changes:

    • The included 3rd party DLLs should no longer cause conflicts with other versions of those DLLs that might exist in the project.

    • Added missing license file.

    • Manual: Fixed issue where documentation would get generated for non-Map Graph APIs.

    Check out the complete changelog here.
     
  33. Tom-Kazansky

    Tom-Kazansky

    Joined:
    Mar 9, 2015
    Posts:
    38
    Hi,
    I think I found the issue,
    I use BSP Tree to generate rooms and connect center points of those rooms to make roads,
    my guess is that the "Room To Node Ratio" is too small and the graph can't get the center points.

    error-guess.png

    after I change the "Room To Node Ratio" to 30 ~ 30, no errors appear even after 20 runs.
     
  34. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    Hmm, do you think the problem might be in the Rectangle Center Points node then? I'll see if I can reproduce the issue.

    Just to be sure, what's the size of the texture that's passed into the Draw Points node? I assume that's also InnerSize?
     
  35. Tom-Kazansky

    Tom-Kazansky

    Joined:
    Mar 9, 2015
    Posts:
    38
    yes, it's InnerSize, which is 30.
     
    Last edited: Sep 20, 2022
  36. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    Thanks for all the information, it's very helpful! :)

    I think I found the problem. The Rectangles Center Points node rounds the center points to their nearest integer value. With rooms that are one pixel wide and/or high, it can round to a point outside of the rectangle itself and thus outside of the bounds of the texture.

    This should be easily solved by always rounding to the lower integer value. I'll make sure this is fixed in the next patch.

    You don't have to wait for that patch, as it should be easy enough to fix by hand.

    If you open the file RectCenterPointsNode.cs, look for these lines:
    Code (CSharp):
    1.                 Mathf.RoundToInt(rect.center.x),
    2.                 Mathf.RoundToInt(rect.center.y))
    And replace them with this:
    Code (CSharp):
    1.                 Mathf.FloorToInt(rect.center.x),
    2.                 Mathf.FloorToInt(rect.center.y))
    Please let me know if this solves the issue for you. :)
     
    Tom-Kazansky likes this.
  37. Tom-Kazansky

    Tom-Kazansky

    Joined:
    Mar 9, 2015
    Posts:
    38
    Hi,
    This works for me!
    I changed some parameters to faster reproduce the issue:
    - number of divisions: 4 ~ 4
    - room to node ratio: 10 ~ 10
    Before code change: got the error every time a room is created on the edges of the texture
    After code change: no errors

    error-fixed.png
    you can see there are 3 rooms on the edges of the texture

    problem solved :D
     
    InsaneScatterbrain likes this.
  38. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    Great! Thanks for your help with finding and solving this. :)
     
  39. Tom-Kazansky

    Tom-Kazansky

    Joined:
    Mar 9, 2015
    Posts:
    38
    Hi,
    I ran into another problem.

    The steps to reproduce:
    - clone a graph that includes some reference nodes
    - rename the cloned graph
    - open the cloned graph: the reference nodes are missing, the nodes will be connected directly
    - close and reopen Unity
    - open the cloned graph again: Graph Editor cannot load the graph, got the following error:
    Code (CSharp):
    1. KeyNotFoundException: The given key was not present in the dictionary.
    2. System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    3. InsaneScatterbrain.ScriptGraph.Editor.ScriptGraphView.ConnectOutputNode (InsaneScatterbrain.ScriptGraph.IConsumerNode node) (at Assets/Plugins/InsaneScatterbrain/ScriptGraph.Editor/ScriptGraphView.cs:579)
    - if I go to code and commented out related lines (ScriptGraphView.cs, 572 ~ 580): Graph Editor can load the graph. (reference nodes are still missing, though)

    if I don't rename the cloned graph: there is no problems, I can open the graph and no reference nodes missing, even if I close/reopen Unity.

    so I guess renaming a ".asset" file is more than just changing the name? maybe Unity did something...
    or there is some problem specific to my graph.:confused:
     

    Attached Files:

  40. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    Thanks again for providing the steps and screenshots! :)

    The cloning and renaming of asset files is handled by Unity itself, so it sounds like it might be a bug in the Unity editor. Especially because it works fine before renaming.

    Unfortunately, I haven't been able to reproduce this issue just yet. It might be dependent on the Unity version. Which version of Unity and Map Graph are you using?
     
  41. Tom-Kazansky

    Tom-Kazansky

    Joined:
    Mar 9, 2015
    Posts:
    38
    Hi,
    I think I have Map Graph v1.18, can you add version to Tools / Map Graph window?
    my Unity version is 2020.3.33f1.

    also, I found a workaround, that is: directly edit the graph file (*.asset) with a text editor, look for referenceNodeConnections, remove all children, leaving [ ], then save the file, now the Graph Editor can open the graph with problem.
    work-around.png notice that "referenceNodes" is empty => missing reference nodes,
    "referenceNodes" in the original graph file is not empty though, I guess it's a problem with Unity's serialization (I don't know what did they do while renaming the file to cause such issue)
     
  42. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    There's a "version.txt" file that should show what version you're currently on, but yeah it would be nicer to just have it in the about window. I'll add that. :)

    I'm glad you found a workaround for your issue. I'm still not able to reproduce it, unfortunately.

    Does this happen with that particular graph? Or are you able to reproduce it with a new graph as well?

    If you have the option, you could try to back up your project and update it to a newer version of Unity and see if that solves the issue.
     
    Tom-Kazansky likes this.
  43. Tom-Kazansky

    Tom-Kazansky

    Joined:
    Mar 9, 2015
    Posts:
    38
    yes, I can reproduce this with a new graph (check my attached image), the new graph is very simple, just draw some random circles, the tileset used is the one in the tutorial.

    I can confirm that renaming the file in Unity did cause the issue, if I change the name of the cloned graph outside Unity (also remove the associated .meta file), then go back to Unity, the cloned/renamed graph is fine.

    I will later check this with newer version of Unity. :)
     

    Attached Files:

    InsaneScatterbrain likes this.
  44. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    Very strange, I did something similar, but no issues. I'll try again, but to be honest I'm not sure if I can do something about it, it still seems like a Unity issue to me.

    Renaming outside of Unity seems like a viable workaround at least.
     
    Tom-Kazansky likes this.
  45. Tom-Kazansky

    Tom-Kazansky

    Joined:
    Mar 9, 2015
    Posts:
    38
    yeah, it's definitely a Unity issue.
    I'm ok with the current workaround, thanks for your support so far :D
    -------------
    is there a way to get an isolated area(s) that is enclosed by a specific color?
    enclosed-area.png enclosed-area2.png
    in the 2nd image above, the generated area is a "forest" so I want the isolated area to also have "Grass" (green tile)
    right now I haven't found a way to retrieve the said area, is this feature available yet?
    if this feature is not yet available, please consider this as feature request.
    (this is specific to my use case so... no rush :p)
     
    InsaneScatterbrain likes this.
  46. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    Yes, that's what the "Inner Areas" port is for on the Extract Areas node. An inner area is basically any area that's not connected to the texture's edges in some way. I think that's exactly what you're looking for here.

    So it would be very similar to what you have in the screenshot, but you'd extract the gray/transparent parts instead. You can then fill the inner areas with grass and the outer areas with dirt. :)

    Does that solve your issue?
     
    Tom-Kazansky likes this.
  47. Tom-Kazansky

    Tom-Kazansky

    Joined:
    Mar 9, 2015
    Posts:
    38
    It works!
    problem-solved.png

    Thank you for your amazing support!:D
     
    InsaneScatterbrain likes this.
  48. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    189
    Great! You're very welcome.

    Let me know if there's anything else I can help with. :)
     
  49. Tom-Kazansky

    Tom-Kazansky

    Joined:
    Mar 9, 2015
    Posts:
    38
    Hi,
    sorry to bother you again.

    my graph is complete, but I notice a minor problem, somehow the horizontal manhattan connection didn't align well if connection width is an even number.

    let me explain a bit about my graph:
    - there are roads that start at the texture's edges
    - these roads must be perpendicular to their respective edges
    - so I create a 2x2 rectangle at the edge, stamp it on the main texture
    - (again) stamp that rectangle with offset towards the center of the texture.
    - connect these two rectangles
    the problem: the horizontal manhattan connection between those rectangles somehow align to the top edge of them so the drawn line isn't straight. (please check image below)
    connection misalign.jpg
    vertical manhattan connection does not have this problem.

    if I change the size of rectangles above to 3x3 and the connection width to 3, the drawn line is straight.
    connection ok.jpg

    so I thought there are some restriction with using even number for connection width?
     
    Last edited: Sep 26, 2022 at 4:54 AM
  50. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    1,965
    Random dev question! Which Node system are you using to code the node editor?
    Is it an open source or custom node graph system?
     
    Last edited: Sep 26, 2022 at 12:28 PM
unityunity