Skip to main content

Class SurveyOverlayGenerator

Presents one or more questionnaire pages as an overlay on top of the running simulation, collecting responses without pausing or ending the game mode session.

public sealed class SurveyOverlayGenerator : BaseSurveyHandler

Inheritance​

Examples​

Trigger the overlay from a vehicle-yield event and react when the participant submits:

[SerializeField] private SurveyOverlayGenerator _overlay;

private void OnEnable() => _overlay.OnAnswerSubmit += OnSurveyComplete;
private void OnDisable() => _overlay.OnAnswerSubmit -= OnSurveyComplete;

// Call this from a UnityEvent or trigger zone when the interaction occurs:
public void ShowTrustRating() => _overlay.GenerateOverlay();

private void OnSurveyComplete() => Debug.Log("Overlay survey complete.");

Remarks​

Use this instead of SurveyPageGenerator when the survey must appear during a scenario — for example, an instant trust-rating prompt triggered immediately after a vehicle interaction. SurveyPageGenerator is for surveys shown between scenarios: it occupies the full screen and calls GameMode.EndSession() on submit. This class keeps the UIDocument disabled at startup so the overlay is invisible until explicitly triggered, and on completion it fires OnAnswerSubmit rather than ending the session, letting the scenario continue.

To show the overlay, call GenerateOverlay from whatever event triggers the prompt (e.g. a vehicle yield event, a timeline signal, or a UnityEvent in the Inspector). Subscribe to OnAnswerSubmit to react when the participant finishes all pages. Data is submitted automatically to SurveyOverlayDataHandler via the service locator.

Properties​

OnAnswerSubmit​

A callback action to be invoked when a survey answer is submitted.

public Action OnAnswerSubmit { get; set; }

Property Value​

Action

Methods​

GenerateOverlay()​

Generates the overlay for the current survey page.

public void GenerateOverlay()

MoveOntoNext()​

Moves to the next survey page or submits the survey if no more pages are left.

protected override void MoveOntoNext()