LocalizeAudioClipEvent
Component that resolves a localized audio clip and forwards it through a UnityEvent whenever the value or the selected locale changes.
Read time 7 minutesLast updated 10 days ago
Definition
- Type: Class
- Namespace: Unity.Localization.Components
- Assembly: UnityEngine.LocalizationRuntimeModule
- Inherits from: LocalizeAssetEvent<AudioClip>
[AddComponentMenu("Localization/Localize Audio Clip Event")]public class LocalizeAudioClipEvent : LocalizeAssetEvent<AudioClip>
Remarks
This is the AudioClip specialization of LocalizeAssetEvent<TObject>. Add it to a GameObject, assign its LocalizeAssetEvent<TObject>.AssetReference in the Inspector, then connect LocalizeAssetEvent<TObject>.OnUpdateAsset to an AudioSource to play voice-over lines or other sounds recorded per language.
Forward the resolved clip to an audio source.
Examples
using Unity.Localization.Components;using UnityEngine;namespace Unity.Localization.Samples{ public class LocalizeAudioClipEventBindingExample : MonoBehaviour { public LocalizeAudioClipEvent localize; public AudioSource target; void OnEnable() => localize.OnUpdateAsset.AddListener(OnUpdate); void OnDisable() => localize.OnUpdateAsset.RemoveListener(OnUpdate); void OnUpdate(AudioClip value) { target.clip = value; target.Play(); } }}
Inheritance
Operators
Operator | Description |
|---|---|
| operator == | Compares two object references to see if they refer to the same object. |
| bool | Determines whether the object exists. |
| operator != | Compares if two objects refer to a different object. |