BroAudio
Quick StartScripting APIAsset Store
  • Overview
    • Introduction
    • Getting Started
    • Compatibility
  • Core Features
    • Library Manager
      • Create The Library
      • Design The Sound
        • 🔊Volume
        • 🎚️Fading
        • 🔁Looping
        • 🎲Randomization
        • 💪Velocity
        • 🎛️Spatial & Mix
    • Audio Player
      • Music Player
      • Dominator Player
    • Playback Group
    • Audio Effect
    • No-Code Components
      • Sound Source
      • Sound Volume
      • Spectrum Analyzer
    • Addressables
    • Customization
  • Designs
    • Audio Mixer
  • Tools
    • Audio Clip Editor
    • Audio Effect Editor
    • Useful Attrubutes
  • Reference
    • Scripting API
      • Class
        • BroAudio
        • SoundSource
        • BroAdvice
      • Interface
        • IAudioPlayer
        • IMusicPlayer
        • IPlayerEffect
        • IAutoResetWaitable
        • IAudioSourceProxy
      • Struct
        • SoundID
        • Effect
        • Fading
      • Enums
        • BroAudioType
        • EffectType
        • StopMode
        • Transition
        • Ease
    • Unity API Integration
    • Audio Terminology
    • Technical Details
  • Others
    • Release Notes
    • Known Issues
      • Duplicate SoundID Issue
    • Roadmap
    • Support & Contact
Powered by GitBook
On this page
  • Description
  • Proxy? Why can't just give us the AudioSource directly?
  1. Reference
  2. Scripting API
  3. Interface

IAudioSourceProxy

A generated proxy code for AudioSource component

Last updated 7 months ago

NameSpace
Accessibility

Ami.Extension

public

Description

This proxy represents the AudioSource component on the AudioPlayer. It allows you to access all the Unity APIs and properties freely. There’s nothing here but bindings to the AudioSource.

Proxy? Why can't just give us the AudioSource directly?

Since BroAudio utilized , we need to reset the AudioSource to its default in order to recycle and reuse safely. There are 3 possible ways to do that:

1. ? AudioSource doesn’t inherit from MonoBehaviour 2. Destroy the component and add it again? That defeats the purpose of object pooling 3. Manually reset all properties seems like the way to go

However, resetting all properties, even those that aren't modified, is inefficient. Unity is natively written in C++, and all C# APIs and properties eventually call the native side, which isn’t free — it produces GC. With around 30 properties in AudioSource, resetting them all after every play session could become an issue, especially since, in most cases, you might have dozens of sounds playing every second.

The proxy class is created after the is accessed, and it will record which property you've modified, and only reset them when the player is about to recycle.

❌
❌
✅
see the full list of the supported APIs
MonoBehaviour.Reset()
object pooling
IAudioPlayer.AudioSource