Skip to content

Component Reference

This reference explains the key Sirocco Race Timing components, what they do, and the important Inspector fields.

Architecture note: business logic lives in Assets/RaceTiming/Core/ (pure C#). Unity integration lives in Assets/RaceTiming/Adapter/ and Assets/RaceTiming/UI/.


RaceTimingManager (MonoBehaviour)

Location: Assets/RaceTiming/Adapter/RaceTimingManager.cs

Role: The Unity-facing entry point. Owns a Core LapTimer, configures sectors/finish conditions, and exposes UnityEvents.

Inspector: Configuration

  • AutoStartSession
  • If enabled, starts the session in Start().
  • SessionConfig (required)
  • Reference to a SessionConfigAsset ScriptableObject containing session identity, countdown configuration, and finish condition settings.
  • Available presets (located in Assets/RaceTiming/Presets/Sessions/):
    • Practice: No countdown, no finish condition (manual stop)
    • Qualifying: Simple countdown (1 light), 15-minute timed session, best lap time order
    • Sprint Race: F1-style countdown (5 lights, 30s pre-start), 10-lap race
    • Feature Race: F1-style countdown (5 lights, 30s pre-start), 50-lap race
    • Endurance Race: F1-style countdown (5 lights, 60s pre-start), 6-hour timed race with race end mode
  • Custom configs: Create your own via Assets > Create > RaceTiming > Session Config

Delta Bar Configuration: - EnableDeltaBar - If enabled, tracks micro-sector timestamps for delta bar calculations. - MaxDelta - Maximum delta in seconds for delta bar clamping. Default: 9.999. - MicroSectorsPerSector - Number of micro-sectors per regular sector. More micro-sectors = finer granularity. Default: 10.

Sector configuration: - Sectors are configured on the track asset (TrackMarkerScriptableObject) via TrackMarkerManagerBehaviour. - RaceTimingManager no longer exposes SectorCount/Sectors in the Inspector. - You can view the resolved sector list at runtime via the read-only ResolvedSectors field.

Inspector: Events (UnityEvents)

These are UnityEvent wrappers around Core events: - OnLapCompleted - OnSectorCrossed - OnSessionStarted, OnSessionFinished - OnCompetitorRegistered - OnPositionChanged, OnStandingsUpdated - OnNewBestLap, OnNewSessionBestLap - OnNewBestSector, OnNewSessionBestSector - OnLappedStateChanged - OnCheckeredFlagOut - OnCountdownStartedUnity (fired when F1-style countdown begins) - OnLightsOutUnity (fired when green lights activate)

Common usage

  • Start: RaceTimingManager.Instance.StartSession()
  • Stop: RaceTimingManager.Instance.StopSession()
  • Access Core: RaceTimingManager.Instance.LapTimer

Delta Bar API: - GetDeltaBarData(competitorId) — Returns DeltaBarData for the specified competitor. - SetReferenceLap(competitorId, lapRecord) — Sets a reference lap for delta calculations.


SessionConfigAsset (ScriptableObject)

Location: Assets/RaceTiming/Adapter/SessionConfigAsset.cs

Role: Unified configuration asset containing session identity, countdown settings, and finish condition parameters. Replaces separate countdown and finish condition fields.

Session Identity

  • SessionName
  • Session name shown in UI (e.g., "Q1", "Practice 1", "Race")
  • SessionTypeLabel
  • Optional display label for session type (e.g., "Qualifying", "Sprint Race")

Countdown Configuration

  • Countdown.Enabled
  • If enabled, session starts with a lights-out countdown sequence
  • Countdown.LightCount (1-5)
  • Number of red lights to illuminate
  • Countdown.RedLightIntervalMs
  • Interval in milliseconds between each red light activation
  • Countdown.GreenWindowMinMs / GreenWindowMaxMs
  • Random delay range after all lights are red before going green
  • Countdown.PreStartDelaySeconds
  • Pre-start delay before red light sequence begins (0 to skip)

Finish Condition Configuration

  • FinishCondition.Type
  • None: Session runs until manually stopped
  • LapCount: Checkered flag after leader completes target lap count
  • Timed: Session ends after configured duration
  • LapCount settings (when Type = LapCount):
  • TargetLapCount: Number of laps required
  • Timed settings (when Type = Timed):
  • DurationSeconds: Session duration in seconds
  • TimedEndMode: Qualifying or Race (affects checkered flag behavior)
  • TimedStandingsOrder: BestLapTime or LapsCompleted

Creating Custom Configs

  1. Assets > Create > RaceTiming > Session Config
  2. Set session identity (name, type label)
  3. Configure countdown (enable/disable and set parameters)
  4. Configure finish condition (type and relevant settings)
  5. Save as a preset for reuse across scenes

Design Benefits

  • Reusability: Save and reuse configurations across scenes
  • Consistency: All session settings in one unified asset
  • Composability: Future race meeting support (array of session configs)
  • Better UX: Asset-based configuration vs. primitive fields

RaceCompetitor (MonoBehaviour)

Location: Assets/RaceTiming/Adapter/RaceCompetitor.cs

Role: Represents a vehicle/driver. Samples position in FixedUpdate and feeds Core timing.

Inspector

  • Id
  • If 0, auto-generated at runtime using GetInstanceID().
  • CompetitorName
  • Defaults to GameObject name if empty.
  • ShortName
  • Optional 3-letter abbreviation for UI.
  • TeamColor
  • Used by UI (exposed as a hex string internally).
  • TrackMarkerManager
  • Optional reference. If not set, auto-finds the first TrackMarkerManagerBehaviour.

Important behavior

  • Runs timing updates in FixedUpdate for deterministic sampling (Time.fixedTimeAsDouble).
  • Uses track markers (if present) to compute a track ratio (0..1) and detect lap wrapping.
  • Reports samples to Core via LapTimer.UpdatePosition(...).

TrackMarkerManagerBehaviour (MonoBehaviour)

Location: Assets/RaceTiming/Adapter/TrackMarkerManagerBehaviour.cs

Role: Unity wrapper around Core track marker management. Also draws gizmos and sector boundary markers.

Inspector

  • trackMarkerScriptableObject
  • The TrackMarkersSO asset containing waypoint positions.

Runtime properties

  • trackMarkers: list of waypoint positions
  • cumulativeDistances: cumulative distances along the loop
  • totalTrackLength: track length in meters

RaceTowerUI (MonoBehaviour)

Location: Assets/RaceTiming/UI/RaceTowerUI.cs

Role: Displays a standings tower. Polls session data each Update.

Inspector

  • RowPrefab: RaceTowerRowUI prefab
  • Container: Transform under a Canvas hierarchy (often with a layout group)
  • Mode: gap display mode
  • GapToLeader
  • GapToAhead
  • GapOnTrack
  • ReferenceDriverId (used by GapOnTrack)
  • -1 = use first driver in standings as reference

Setup guide

See: UI Setup: RaceTowerUI


RaceTowerRowUI (MonoBehaviour)

Location: Assets/RaceTiming/UI/RaceTowerRowUI.cs

Role: Binds a single row of UI.

Inspector

Text references: - PositionText, NameText, GapText, LapText, RatioText

Visuals: - TeamColorStrip (Image)


RaceToastBridge (MonoBehaviour)

Location: Assets/RaceTiming/UI/RaceToastBridge.cs

Role: Subscribes to Sirocco Race Timing UnityEvents and shows toast notifications.

Requirements

  • A UnityToast.ToastManager in the scene.

Inspector

Event filters: - Lap completions, personal bests, session bests - Position changes - Personal best sectors, session best sectors

Also supports optional icons and configurable colors.


DeltaBarUI (MonoBehaviour)

Location: Assets/RaceTiming/UI/DeltaBarUI.cs

Role: Displays a live delta bar overlay showing real-time comparison against a reference lap. Shows whether the driver is faster or slower than the reference at each micro-sector.

Requirements

  • A RaceTimingManager in the scene.
  • CompetitorFocusManager for tracking focused competitor.
  • TrackMarkerScriptableObject with MicroSectorsPerSector configured.

Inspector: Configuration

  • FocusedCompetitorId
  • Specific competitor ID to track. If 0 (default), uses CompetitorFocusManager.

Inspector: UI References

  • DeltaBarImage (Image)
  • The main bar fill image. Uses Image fill origin to show direction.
  • DeltaText (TextMeshProUGUI)
  • Numeric delta display (e.g., "-0.523" or "+1.247").

Inspector: Visuals

  • FasterColor (Color)
  • Color for positive delta (driver ahead/faster). Default: Green.
  • SlowerColor (Color)
  • Color for negative delta (driver behind/slower). Default: Red.
  • NeutralColor (Color)
  • Color for zero delta. Default: White.
  • MaxDelta
  • Maximum delta in seconds for full bar fill. Default: 9.999.

How It Works

  1. Subscribes to CompetitorFocusManager to track focused competitor.
  2. Polls RaceTimingManager.GetDeltaBarData() each frame.
  3. Updates bar fill based on DeltaBarData.TotalDelta.
  4. Updates text color based on delta sign.
  5. Hidden when DeltaBarData.IsActive is false.

Keyboard Control (Demo)

In demo scenes, press K to toggle delta bar visibility.


LapPositionBarUI (MonoBehaviour)

Location: Assets/RaceTiming/UI/LapPositionBarUI.cs

Role: Displays a horizontal bar overlay showing all competitors as colour-coded dots positioned by their normalised lap progress (0.0–1.0). Provides an at-a-glance view of the field spread around the circuit.

Requirements

  • A RaceTimingManager in the scene.
  • CompetitorFocusManager for identifying the focused competitor.

Inspector: Colors

  • LeaderColor (Color)
  • Color for the race leader's dot. Default: Red.
  • FocusedColor (Color)
  • Color for the focused competitor's dot. Default: Green.
  • DefaultColor (Color)
  • Color for all other competitors' dots. Default: Grey.

Inspector: Pool Settings

  • InitialPoolSize (int)
  • Number of dot Images to pre-allocate. Default: 30.
  • If more competitors are registered, additional dots are instantiated on demand.

Inspector: Dot Appearance

  • DotSize (float)
  • Size of each dot in pixels. Default: 12.
  • BarHeight (float)
  • Height of the bar in pixels. Default: 20.

Inspector: UI References

  • DotContainer (RectTransform)
  • Container for positioning dots. Auto-created if not assigned.

How It Works

  1. Queries LapTimer.QueryTrackPositionIntervals() each frame in LateUpdate().
  2. Positions each dot horizontally based on TrackPositionEntry.TrackPosition (0.0–1.0).
  3. Applies colour priority: Focused (green) > Leader (red) > Default (grey).
  4. Manages a dot pool to avoid per-frame allocations.
  5. Deactivates unused dots when competitor count decreases.

Keyboard Control (Demo)

In demo scenes, press L to toggle lap position bar visibility.


StartLightsUI (MonoBehaviour)

Location: Assets/RaceTiming/UI/StartLightsUI.cs

Role: Displays F1-style start lights during the session countdown. Subscribes to countdown events on the RaceTimingManager.

Requirements

  • A RaceTimingManager in the scene.
  • Configured as part of the SessionConfig with a valid countdown.

Inspector: Visuals

  • Array of Image references for the lights.

CarFocusIndicatorUI (MonoBehaviour)

Location: Assets/RaceTiming/UI/CarFocusIndicatorUI.cs

Role: Adds visual brackets on-screen highlighting the currently focused competitor's car on the track. Follows the car's screen position.

Requirements

  • CompetitorFocusManager for tracking focused competitor.

Inspector: Configuration

  • Use Team Color: Check to use the focused competitor's team color instead of a static color.
  • Highlight Color: Static color fallback.
  • Smoothing applied for following.

Keyboard Control (Demo)

In demo scenes, press N to cycle focused competitors.


QualifyingLapUI (MonoBehaviour)

Location: Assets/RaceTiming/UI/QualifyingLapUI.cs

Role: Provides a detailed overlay of sector times and lap splits specifically for the focused car. Highlights best and personal best sectors.

Requirements

  • A RaceTimingManager in the scene.
  • CompetitorFocusManager for identifying the focused competitor.

Inspector: Configurations

  • Visual colours for Default, Slower, Personal Best, and Session Best.

Keyboard Control (Demo)

In demo scenes, press Q to toggle qualifying UI visibility.