Skip to content

Troubleshooting: Analysing Generation Performance & Process

When your dungeon generation isn't working as expected, whether it's failing frequently, taking too long, or producing undesirable layouts, you need ways to diagnose the problem. DunGen provides tools and features to help you analyse the performance and visualize the step-by-step process of dungeon creation.


Generation Statistics

The generation statistics window provides some simple information about your successful dungeon generation.

  • What it Does: Provides a list of basic statistics including total generation time, the number of rooms of each type that were spawned, total retry count, and how long each step in the generation process took.
  • How to Use:
    1. Open the generation statistics window (Window > DunGen > Generation Stats).
    2. Generate a dungeon. This can be done at runtime using the Runtime Dungeon component or in the editor (Window > DunGen > Generate Dungeon).
    3. The window will update to show that stats of the last generated dungeon. Generating another dungeon will update the stats for the new dungeon generation.

Runtime Analyzer Component

For quantitative analysis, especially regarding performance and success rates over multiple runs, DunGen provides the Runtime Analyzer component.

  • What it Does: This component repeatedly generates dungeons using specified settings and gathers statistics about the process, such as average generation time, failure rates, and time spent on different generation steps.
  • How to Use (Easiest Way):
    1. Locate the demo scene provided with DunGen: Assets/DunGen/Demo/Analysis Scene.
    2. Open this scene.
    3. Find the Analyzer GameObject in the hierarchy.
    4. In the Inspector, find the Runtime Dungeon (Script) component attached to the Analyzer GameObject.
    5. Replace the default Dungeon Flow asset in its slot with your own Dungeon Flow asset that you want to test.
    6. Enter Play mode. The analyser will run multiple generation cycles (configurable on the Runtime Analyzer component) and print the statistics to the Console once finished.
  • How to Use (Manual Setup):
    1. Add the Runtime Analyzer component to a GameObject in your scene (Add Component > DunGen > Analysis > Runtime Analyzer).
    2. Ensure this GameObject also has a Runtime Dungeon component configured with your desired settings.
    3. Configure the Runtime Analyzer settings (number of iterations, etc.).
    4. Enter Play mode.
  • What Information it Provides:
    • Total number of successful generations vs. attempts.
    • Average time taken per successful generation.
    • Average time spent on specific phases (e.g., Main Path Generation, Branch Path Generation, Post-Processing).
    • Average number of rooms in total, as well as individually on the Main Path and Branch Paths.
  • Why it's Useful:
    • Identifies performance bottlenecks (which step takes the longest?).
    • Quantifies the impact of changes (e.g., did adding more complex tiles significantly increase generation time?).
    • Helps determine if generation failures are frequent or rare under specific rule sets.

Asynchronous Generation Visualization

Sometimes, seeing how the dungeon is built step-by-step is more revealing than statistics, especially when debugging layout failures or unexpected tile placements. You can achieve this using DunGen's asynchronous generation mode with pauses.

  • What it Does: Allows DunGen to generate the dungeon over multiple frames and optionally pause after placing each Tile, letting you watch the process unfold in the Scene view.
  • How to Enable:
    1. Select the GameObject containing your Runtime Dungeon component.
    2. In the Inspector, find these settings:
      • Generate Asynchronously: Check this box. This tells DunGen not to block the main thread during generation, enabling pauses.
      • Pause Between Rooms: Set this to a small positive value (e.g., 0.5 or 1.0). This is the duration (in seconds) DunGen will pause after placing each room/tile. A value of 0 means no pause.
    3. Enter Play mode. Observe the Scene view as the dungeon constructs itself incrementally.
  • Why it's Useful:
    • Visual Debugging: See the exact order tiles are placed and connected.
    • Failure Point Identification: If generation fails, you can often see exactly which tile placement failed or where the process got stuck.
    • Understanding Logic: Visually grasp how main path vs. branch path generation proceeds, how connection rules are applied, or why certain areas might be unreachable.
    • Collision Issues: Helps spot if tiles are colliding unexpectedly with each other or scene objects during placement.

By utilizing the Runtime Analyzer for performance metrics and asynchronous visualization for process debugging, you gain valuable insights into how DunGen is operating, making it much easier to troubleshoot issues and optimize your procedural dungeon generation setup.