Virtual Pet Game Template
  • VIRTUAL PET GAME TEMPLATE
  • Getting Started
    • 🎯 Project Setup Guide
    • 🧩 Home Scene Overview
    • 🗺️ UI Main Menu
    • 🗺️ LoadingManager
    • 🗺️ GameInstance
    • 🗺️ ToolsManager
    • 🗺️ AudioManager
    • 🗺️ LanguageManager
    • 🗺️ MonetizationManager
    • 🗺️ PlayerSave
  • Modifying the project
    • 🐾 How to Add a New Pet
    • 📜How Add a New Pet Rules
    • 💰 How to Add a New Currency
    • 🍎 How to Add a New Food Item
    • 🧢 Adding a New Accessory
    • 🎮 How to Add a New Minigame
  • Modifying Minigames
    • 🌤️ Minigame "Jump Sky"
    • 🍔 Minigame "Food Flicker"
    • 🐦 Minigame “Flappy”
    • 💎 Minigame “Gem Hunter”
Powered by GitBook
On this page
  • 🎵 What It Does
  • 🔧 Inspector Configuration
  • 🧠 How It Works
  • 🔍 Integration Examples
  • ✅ Highlights
  1. Getting Started

🗺️ AudioManager

AudioManager – Component Overview

The AudioManager is a centralized system for playing, looping, and managing audio in the Virtual Pet Game Template. It allows tag-based volume control, simultaneous SFX playback, ambient loops, and dynamic volume adjustments through settings UI.


🎵 What It Does

  • Handles one-shot sound effects with concurrency limit

  • Supports looping sounds by tag (e.g., rain, shower)

  • Plays ambient and loading background music independently

  • Allows custom tag volume control for specific gameplay needs

  • Saves and loads volume preferences via PlayerPrefs


🔧 Inspector Configuration

  • Audio Sources:

    • masterAudioSource: main SFX source

    • ambientAudioSource: looped ambience

    • loadingAudioSource: loading screen music

  • Volume Settings:

    • masterVolume, vfxVolume, ambienceVolume

    • customTagVolumes: per-tag volume definitions

  • Limitations:

    • maxConcurrentAudio: limits how many SFX can play at once


🧠 How It Works

Initialization

  • Loads volume preferences from PlayerPrefs

  • Sets initial volume on audio sources

  • Ensures ambientAudioSource loops

One-Shot Audio

AudioManager.Singleton.PlayAudio(clip, "vfx");
  • Plays an SFX using the master audio source

  • Checks for concurrency limit

  • Uses per-tag volume control

Looping Audio

AudioManager.Singleton.StartLoop(clip, "shower");
  • Starts a looping sound for a tag (adds AudioSource if missing)

AudioManager.Singleton.StopLoop("shower");
  • Stops and removes looping source for a tag

Ambient & Loading

  • PlayAmbientAudio(clip) plays persistent ambiance

  • PlayLoadingMenu(clip) plays loading screen music

Volume Control (Settings Menu)

AudioManager.Singleton.SetBuiltInVolume("master", 0.8f);
  • Updates built-in volume and saves to PlayerPrefs

AudioManager.Singleton.SetCustomTagVolume("shower", 0.6f);
  • Adds/updates volume for custom tags


🔍 Integration Examples

  • Play a sound effect:

AudioManager.Singleton.PlayAudio(sfxClip, "vfx");
  • Play ambient track:

AudioManager.Singleton.PlayAmbientAudio(ambientClip);
  • Loop sound by tag:

AudioManager.Singleton.StartLoop(waterClip, "shower");
  • Update VFX slider:

AudioManager.Singleton.SetBuiltInVolume("vfx", slider.value);

✅ Highlights

  • 🎧 Centralized one-shot and looping playback

  • ⚖️ Per-tag volume and concurrency cap

  • ☁️ Ambient / loading music separation

  • ↺ Dynamic control for UI settings

A robust and modular audio solution tailored for casual mobile games, pet simulators, and minigame-driven environments.

Previous🗺️ ToolsManagerNext🗺️ LanguageManager

Last updated 28 days ago