Class
UnituneSource

Summary

Syntax

[RequireComponent(typeof(AudioSource))]
[AddComponentMenu("Audio/Unitune Source")]
public class UnituneSource : MonoBehaviour

Fields

Name Field Type Summary
createAudioClipOnEnable bool
Wether to call TryCreateAudioClip() when the script is enabled. Always considered true when the AudioSource's PlayOnAwake is on.
duration float
The duration (in seconds or normalized time) of the audio to be played. If the duration exceeds the length of the selected subsong(s), that additional portion will be silent.
from float
The starting point (in seconds or normalized time) from which to begin playback.
stereoSeparation float
The generated stereo separation. The default value is 1f. The supported value range is [0f, 2f].
subsongIndex int
The index of the subsong to be played from the module.
unituneAsset UnituneAsset
The UnituneAsset that will be converted into an AudioClip.
useNativeLoopPoint bool
Whether to use the module loop point at the end of the song instead of the AudioSource loop.

This option only works with streaming enabled and requires the AudioSource's loop parameter to be enabled.

It's also important to note that enabling this option will prevent any seeking capabilities: Stop/Play will act like a Pause/Unpause and Time/TimeSamples will always result in a small jump backward in samples.

useNormalizedTime bool
Whether to normalize the time values for from and duration based on the module's total duration.
useOutputChannels bool
Whether to use the output channels configuration from the current audio settings.
useOutputSampleRate bool
Whether to use the output sample rate from the current audio settings.
useStreaming bool
Whether to use streaming for audio playback. If enabled, the audio will be streamed instead of fully loaded into memory.

Properties

Name Property Type Summary
Channels ChannelCount
SampleRate int
StreamingModule Module

The current underlying module being streamed. It will always be null on WebGL as that platform doesn't support audio streaming. Make sure that this module is not null before using it.

It's not necessary to dispose of this module. It will be done automatically by the UnituneSource component.

Methods

Name Return Value Summary
AudioSpeakerModeToChannelCount(AudioSpeakerMode) ChannelCount
Converts an AudioSpeakerMode to the corresponding ChannelCount.
static
GetSamples() float[]
Generate the sample data based on the UnituneSource settings.
Play() bool
Create an AudioClip based on the current settings, set it to the AudioSource and play the clip.
TryCreateAudioClip() bool
Attempt to create an AudioClip based on the current settings and set it to the clip field of the AudioSource.
TryCreateAudioClip(Module) bool
Attempt to create an AudioClip based on the current settings and set it to the clip field of the AudioSource.