AudioAsset
Ease
FastString
FontAsset
NineSlice
PackedSprite
PackedSpriteID
RB
   HardwareSettings
   IRetroBlitGame
RBAsset
Rect2i
ShaderAsset
SoundReference
SpriteGrid
SpriteSheetAsset
TMXMapAsset
   TMXLayer
   TMXLayerLoadState
   TMXObject
   TMXObjectGroup
   TMXProperties
Vector2i

AudioAsset.Load

Method

public RB.AssetStatus Load(string filename, RB.AssetSource source = RB.AssetSource.Resources)
public RB.AssetStatus Load(AudioClip existingClip)

Parameters

filename string File name
source RB.AssetSource Asset source type
existingClip AudioClip Existing AudioClip

Returns

RB.AssetStatus

Load status

Description

Load an audio asset which can be used to play a sound or play music. There are various asset sources supported:

  • Resources - Synchronously loaded audio assets from a Resources folder. This was the only asset source supported in RetroBlit prior to 3.0.
  • ResourcesAsync - Asynchronously loaded audio assets from a Resources folder.
  • WWW - Asynchronously loaded audio assets from a URL.
  • AddressableAssets - Asynchronously loaded audio assets from Unity Addressable Assets.
  • Existing Assets - Synchronously loaded audio assets from an existing Unity AudioClip.

If the asset is loaded via a synchronous method then Load will block until the loading is complete. If the asset is loaded via an asynchronous method then Load will immediately return and the asset loading will continue in a background thread. The status of an asynchronous loading asset can be check by looking at RBAsset.status, or by using the event system with RBAsset.OnLoadComplete to get a callback when the asset is done loading.

Example

AudioAsset sndBleepBloop = new AudioAsset();

public void Initialize()
{
    // Load asset from Resources asynchronously. This method call will immediately return without blocking.
    sndBleepBloop.Load("bleepbloop"RB.AssetSource.ResourcesAsync);
}

public void Update()
{
    if (RB.AnyKeyPressed() && sndBleepBloop.status == RB.AssetStatus.Ready)
    {
        RB.SoundPlay(sndBleepBloop);
    }
}

See Also

RB.Result
RB.AssetStatus
RB.AssetSource

See Docs

Features - Audio
Features - Asynchronous Asset Loading