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:
- Open the generation statistics window (
Window > DunGen > Generation Stats). - Generate a dungeon. This can be done at runtime using the
Runtime Dungeoncomponent or in the editor (Window > DunGen > Generate Dungeon). - 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.
- Open the generation statistics window (
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):
- Locate the demo scene provided with DunGen:
Assets/DunGen/Demo/Analysis Scene. - Open this scene.
- Find the
AnalyzerGameObject in the hierarchy. - In the Inspector, find the
Runtime Dungeon (Script)component attached to theAnalyzerGameObject. - Replace the default
Dungeon Flowasset in its slot with your ownDungeon Flowasset that you want to test. - Enter Play mode. The analyser will run multiple generation cycles (configurable on the
Runtime Analyzercomponent) and print the statistics to the Console once finished.
- Locate the demo scene provided with DunGen:
- How to Use (Manual Setup):
- Add the
Runtime Analyzercomponent to a GameObject in your scene (Add Component > DunGen > Analysis > Runtime Analyzer). - Ensure this GameObject also has a
Runtime Dungeoncomponent configured with your desired settings. - Configure the
Runtime Analyzersettings (number of iterations, etc.). - Enter Play mode.
- Add the
- 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:
- Select the GameObject containing your
Runtime Dungeoncomponent. - 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.5or1.0). This is the duration (in seconds) DunGen will pause after placing each room/tile. A value of0means no pause.
- Enter Play mode. Observe the Scene view as the dungeon constructs itself incrementally.
- Select the GameObject containing your
- 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.