Visual Debugger Overview

Using the Flow Debugger

NOPE-PRO Visual Debugger Guide

The NOPE-PRO Visual Debugger provides real-time visualization of your Result chains, making it easy to understand complex operation flows and debug issues.

Overview

The Visual Debugger transforms your Result chains into visual flows showing:

  • Success Path (Green): Operations that completed successfully
  • Failure Path (Red): Operations that failed with errors
  • Handled Path (Yellow): Failed operations properly handled by Match/Finally

Architecture

Key Features

  • Real-time flow tracking with millisecond precision
  • Thread-safe operation recording
  • Caller information tracking (file, line, method)
  • Visual distinction between success, failure, and handled paths
  • Railway-oriented visualization in Editor

Enabling Visual Debugging

Step 1: Enable Debug Mode

  1. Go to Window → NOPE PRO → Settings
  2. Toggle Debug Mode to enable
  3. Click Apply Changes
  4. Unity will automatically add NOPE_PRO_DEBUG to Scripting Define Symbols and recompile

Option B: Manual Configuration

  1. Go to Edit → Project Settings → Player
  2. Under Other Settings → Configuration
  3. Add NOPE_PRO_DEBUG to Scripting Define Symbols
  4. Click Apply

Step 2: Enable Debug on Results

Add .EnableDebug() to any Result chain:

1var result = LoadData()
2    .EnableDebug("MyFlow")  // Start tracking with a name
3    .Bind(ProcessData)
4    .Map(TransformData)
5    .Match(
6        onSuccess: data => { SaveData(data); return data; },
7        onFailure: error => { HandleError(error); return default; }
8    );

Using the Flow Debugger Window

Opening the Window

Go to Window → NOPE PRO → Flow Debugger

Window Layout

  1. Toolbar

    • Clear All: Remove all tracked flows (with confirmation)
    • Enable Tracking: Toggle flow tracking on/off
    • Auto Refresh: Toggle automatic UI updates
    • Statistics: Shows Active/Done/Steps counts
  2. Flow List Panel (Left)

    • Active Flows: Currently executing operations
    • Completed Flows: Finished flows (up to 100)
    • Each flow shows:
      • Flow name
      • Status badge (ACTIVE/SUCCESS/HANDLED/FAILED)
      • Step count
      • Start time
      • Duration (for completed flows)
    • Click to select a flow for detailed view
  3. Flow Visualization Panel (Right)

    Flow Details Section:

    • Flow name and unique ID
    • Method and file location (clickable)
    • Overall status with color indicator
    • Total duration and step count
    • Success rate percentage

    Railway Visualization:

    • Horizontal railway-style flow chart
    • Success track (top) and Failure track (bottom)
    • Each node shows:
      • Operation name
      • Type transformation (T→U)
      • Execution time
      • Value/Error preview
    • Branch connections when flow switches tracks
    • Final result indicator

    Selected Node Details:

    • Full operation information
    • Input/Output types
    • Execution time with performance warnings
    • Thread ID and timestamp
    • Source location (clickable)
    • Full value/error inspection (when debug enabled)

Visual Indicators

  • 🟢 Success: Flow completed successfully
  • 🔴 Failure: Flow failed with unhandled error
  • 🟡 Handled: Flow failed but was properly handled
  • 🔵 Active: Flow currently executing

Using the Runtime Overlay

Activating the Overlay

  • Use FlowDebuggerOverlay component.

  • Press F9 during play mode to toggle the overlay.

Overlay Features

  • Active Flows: Currently executing operations
  • Recent Flows: Last completed flows
  • Flow Details: Operation steps with timing
  • Color Coding: Same as editor window

NOPE Settings Window

Access via Window → NOPE PRO → Settings

Available Settings

  1. Debug Mode

    • Enables/disables NOPE_PRO_DEBUG define
    • Required for visual debugging features
  2. Async Support (mutually exclusive)

    • UniTask Support: Enable UniTask integration
    • Unity Awaitable Support: Enable Unity 2023.1+ awaitable support
  3. Window Settings

    • Auto-show on Startup: Show settings on project open
  4. System Information

    • Shows Unity version
    • UniTask package status
    • Awaitable support availability
    • Current build target

Quick Actions

  • Open Player Settings: Direct access to project settings
  • Open Package Manager: Install UniTask if needed
  • Open Flow Debugger: Quick access to debugger window

Available Extension Methods

All extension methods maintain railway-oriented programming semantics while adding tracking:

Starting Debug Flows

1// Start a new debug flow
2result.EnableDebug("FlowName")
3
4// Attach to existing flow context
5result.AttachDebug(existingFlowId)

Object Inspection

When NOPE_PRO_DEBUG is enabled, the Flow Debugger Window provides deep object inspection:

Practical Examples

Basic Flow Tracking

1public Result<Player, string> LoadPlayer(string id)
2{
3    return FetchFromDatabase(id)
4        .EnableDebug($"LoadPlayer_{id}")
5        .Bind(ValidatePlayerData)
6        .Map(DeserializePlayer)
7        .Tap(p => Debug.Log($"Loaded: {p.Name}"));
8}

Complex Chain with Error Handling

1public Result<Order, string> ProcessOrder(OrderRequest request)
2{
3    return ValidateRequest(request)
4        .EnableDebug($"Order_{request.OrderId}")
5        .Bind(req => CheckInventory(req.Items))
6        .Bind(_ => ProcessPayment(request.Payment))
7        .Map(_ => CreateOrder(request))
8        .TapSafe(order => SendEmailNotification(order))
9        .Finally(result => 
10        {
11            LogOrderResult(result);
12            return result;
13        });
14}

Async Operations with UniTask

1#if NOPE_UNITASK
2public async UniTask<Result<Data, string>> LoadDataAsync()
3{
4    var result = await FetchFromServerAsync();
5    
6    return result
7        .EnableDebug("AsyncDataLoad")
8        .Bind(data => ValidateDataAsync(data))
9        .Map(data => TransformData(data))
10        .Tap(data => CacheData(data));
11}
12#endif

Manual Flow Control

1// Manual flow control with FlowDebugger.Begin()
2// Advantage 1: Track multiple independent Result chains in a single debug session
3using (var debug = FlowDebugger.Begin("ManualFlow"))
4{
5    // First Result chain - user authentication
6    var authResult = AuthenticateUser("user123")
7        .AttachDebug(debug)  // Attach to the same debug context
8        .Map(user => $"Authenticated: {user}")
9        .Tap(x => Debug.Log($"Auth: {x}"));
10
11    // Second Result chain - load user data (only if auth succeeded)
12    var dataResult = authResult.IsSuccess
13        ? LoadUserData("user123")
14            .AttachDebug(debug)  // Same debug session tracks both flows
15            .Map(data => $"Data: {data}")
16            .Tap(x => Debug.Log($"Data: {x}"))
17        : Result<string, string>.Failure("Cannot load data - auth failed");
18
19    // Third Result chain - process combined results
20    var finalResult = Result.CombineValues(authResult, dataResult)
21        .AttachDebug(debug)  // All three chains tracked together
22        .Map(results => $"Combined: {results[0]} | {results[1]}")
23        .Finally(res => res.IsSuccess ? "All operations succeeded" : "Operation failed");
24
25    Debug.Log($"Final Result: {finalResult}");
26
27    // Advantage 2: All flows complete together when the using block ends
28    // This ensures related operations are grouped in the debugger
29}

Performance Considerations

  • Minimal overhead when NOPE_PRO_DEBUG is not defined
  • Use conditional debugging for performance-critical paths
  • Delete all debug code before release.

Troubleshooting

Debug Not Working

  1. Verify NOPE_PRO_DEBUG is defined via NOPE Settings
  2. Ensure Enable Tracking is toggled on in Flow Debugger
  3. Check that .EnableDebug() is called on your Result chain
  4. Verify the operation actually executed

Missing Flow Data

  • Flows auto-complete after 5 seconds of inactivity
  • Maximum 100 completed flows are retained
  • Check if flow was replaced due to memory limits
  • Ensure Auto Refresh is enabled for real-time updates

Performance Impact

  • Disable NOPE_PRO_DEBUG for release builds
  • Use conditional compilation for production code
  • Monitor active flow count in toolbar statistics
  • Clear old flows periodically if debugging long sessions

Summary

The Visual Debugger provides comprehensive flow tracking with:

  • ✅ Real-time Editor window with railway visualization
  • ✅ Runtime overlay for in-game debugging
  • ✅ Thread-safe operation recording
  • ✅ Automatic memory management
  • ✅ Deep object inspection capabilities
  • ✅ NOPE Settings window for easy configuration
  • ✅ Production-ready with conditional compilation