PatchAudio: Region Loop Tool
v1.0.0 · Updated 11/3/2025
Overview
PatchAudio: Region Loop Tool is a pure Unity C# tool for handling music with multiple looping regions (Intro → Loop(s) → Outro).
- Define regions visually in a RegionDefinition asset.
- Supports dynamic loop switching, crossfade, and simple API calls.
- Designed for JRPGs, rhythm games, visual novels, or any project needing structured, dynamic looping.
- No FMOD, Wwise, or external middleware required.
Features
- Easy Setup: Create a RegionDefinition asset and set start/end times.
- Multiple Regions: Intro, any number of Loops (A, B, etc.), optional Outro.
- Dynamic Loop Switching: Switch to another loop at the next boundary.
- Simple API:
- musicPlayer.Play("Intro")
- musicPlayer.SwitchLoop("Loop B")
- musicPlayer.End()
- musicPlayer.Stop()
- Editor Timeline Preview: Region bars, playback cursor, preview controls.
- Optional Crossfade on loop transitions.
- Pure Unity C# – no external dependencies.
Getting Started
- Open the demo scene: Assets/PatchAudio/RegionLoopTool/Demo/Scenes/RegionLoopDemo.unity
- Select the region definition asset: Assets/PatchAudio/RegionLoopTool/Demo/Data/DemoRegionDefinition.asset
- Assign an AudioClip.
- Configure region markers (start, end, loop flag, crossfade length).
- Enter Play Mode and use the on-screen demo UI or inspector buttons.
Example Region Layout:
| Region | Start → End | Notes |
|---|---|---|
| Intro | 0s → 4s | Plays once |
| Loop A | 4s → 16s | Default loop |
| Loop B | 16s → 28s | Alternate loop |
| Outro | 28s → 32s | One‑shot ending |
Demo UI
When you press Play in the demo scene, buttons appear:
| Button | Action |
|---|---|
| Play Intro | Plays Intro then enters Loop A |
| Loop A | Switch (or stay) to Loop A at next loop boundary |
| Loop B | Switch to Loop B at next loop boundary |
| End | Play Outro when current loop finishes, then stop |
| Stop | Immediate stop (no Outro) |
(You can also control playback via the RegionMusicPlayer inspector quick buttons.)
Core API Summary
| Method | Description |
|---|---|
| Play(string regionNameOrIntroAlias) | Starts playback; if region is non-looping (e.g. Intro) and a looping region follows, it will continue into the first looping region. |
| SwitchLoop(string loopRegionName) | Queues a switch to another looping region at the next loop wrap. |
| End() | Schedules Outro after the current loop completes, then stops the AudioSource. |
| Stop() | Immediately stops playback. |
Region names must match those defined in the RegionDefinition.
Tips for Clean Loops
- Trim leading/trailing silence in your DAW.
- Export at 44.1kHz or 48kHz (matches Unity defaults).
- Ensure loop boundaries align with zero-crossings.
- Optional: set BPM in the asset (UI hint only).
Key Assets (Demo)
Assets/ PatchAudio/ RegionLoopTool/ Demo/ Scenes/RegionLoopDemo.unity Data/DemoRegionDefinition.asset
License (Summary)
Commercial use inside your game is allowed. Redistribution of the source as a competing standalone tool is not permitted.
FAQ (Quick)
Q: Does it support multiple simultaneous music layers? A: Not in this version (single AudioSource).
Q: Can I fade between loops? A: Yes, enable crossfade in region settings.
Q: Do I need Addressables? A: No. Standard AudioClip references are used.
Q: Does it work in builds? A: Yes, fully runtime safe.

