Patch0x08 Logoassets

PatchAudio: Simple BG Crossfader

v1.0.0 · Updated 11/3/2025

Overview

Simple BG Crossfader provides a tiny component to crossfade background tracks without clicks or abrupt changes. It manages two channels and fades volume between them using a coroutine.

Installation

  1. Import the unitypackage into your Unity project.
  2. Add the Crossfader component to a GameObject in your scene.
  3. Assign two AudioSources (A/B) for crossfading.

Demo Project Structure

This folder contains a minimal demo for the Simple BGM Crossfader.

Contents:

  • Scenes/DemoCrossfader.unity Example scene showing how to set up the crossfader in a Unity scene.

  • Audios/ Place your own test audio files here. Suggested names: TitleIntro.wav (optional, plays once before looping) TitleLoop.wav (main loop for title screen) GameplayLoop.wav (loop for gameplay background)

  • BgmDefinitions/ Store BgmDefinition assets here.

How to Test the Demo

  1. Copy your audio files into Demo/Audios/ (WAV/OGG recommended). Example:

    • TitleIntro.wav
    • TitleLoop.wav
    • GameplayLoop.wav
  2. Create BgmDefinition assets:

    • Right-click in the Project window → Create → PatchAudio → BGM Definition
    • For "Title Bgm": • Intro = TitleIntro.wav (optional) • Loop = TitleLoop.wav
    • For "Gameplay Bgm": • Loop = GameplayLoop.wav
  3. Open Scenes/DemoCrossfader.unity

  4. Select the "DemoController" GameObject in the scene.

    • Drag your TitleBgm.asset into the Title Bgm field.
    • Drag your GameplayBgm.asset into the Gameplay Bgm field.
  5. Press Play.

    • The demo will start playing the Title BGM.
    • You can trigger crossfade to the Gameplay BGM using the provided script.