docs.unity3d.com

Localization 1.5.1

Search Results for

    Show / Hide Table of Contents

    Class LocalizedAudioClip

    Provides a specialized LocalizedAsset<TObject> which can be used to localize AudioClip assets.

    Inheritance
    object
    LocalizedReference
    LocalizedAssetBase
    LocalizedAsset<AudioClip>
    LocalizedAudioClip
    Implements
    ISerializationCallbackReceiver
    Inherited Members
    LocalizedAsset<AudioClip>.WaitForCompletion
    LocalizedAsset<AudioClip>.CurrentLoadingOperationHandle
    LocalizedAsset<AudioClip>.AssetChanged
    LocalizedAsset<AudioClip>.HasChangeHandler
    LocalizedAsset<AudioClip>.LoadAssetAsync()
    LocalizedAsset<AudioClip>.LoadAssetAsync<T>()
    LocalizedAsset<AudioClip>.LoadAssetAsObjectAsync()
    LocalizedAsset<AudioClip>.LoadAsset()
    LocalizedAsset<AudioClip>.ForceUpdate()
    LocalizedAsset<AudioClip>.Reset()
    LocalizedAsset<AudioClip>.CurrentLoadingOperation
    LocalizedAsset<AudioClip>.RegisterChangeHandler(LocalizedAsset<AudioClip>.ChangeHandler)
    LocalizedAsset<AudioClip>.ClearChangeHandler()
    LocalizedReference.m_CurrentTable
    LocalizedReference.m_CurrentTableEntry
    LocalizedReference.TableReference
    LocalizedReference.TableEntryReference
    LocalizedReference.FallbackState
    LocalizedReference.LocaleOverride
    LocalizedReference.IsEmpty
    LocalizedReference.SetReference(TableReference, TableEntryReference)
    Namespace: UnityEngine.Localization
    Assembly: Unity.Localization.dll
    Syntax
    [Serializable]
    public class LocalizedAudioClip : LocalizedAsset<AudioClip>, ISerializationCallbackReceiver
    Examples

    This example shows how to use the LocalizedAudioClip in a MonoBehaviour.

    using UnityEngine;
    using UnityEngine.Localization;
    
    public class LocalizedAudioClipExample : MonoBehaviour
    {
        public AudioSource audioSource;
        public LocalizedAudioClip localizedAudioClip = new LocalizedAudioClip
        {
            TableReference = "My Audio Table",
            TableEntryReference = "My Audio Clip",
        };
    
        void OnEnable()
        {
            // Starts loading the audio clip asynchronously.
            localizedAudioClip.AssetChanged += AudioAssetChanged;
        }
    
        void OnDisable()
        {
            localizedAudioClip.AssetChanged -= AudioAssetChanged;
        }
    
        /// <summary>
        /// Changes the audio clip to the one specified by the <see cref="audioName"/>.
        /// </summary>
        /// <param name="soundName"></param>
        public void PlaySound(string soundName)
        {
            // This will trigger an automatic update
            localizedAudioClip.TableEntryReference = soundName;
        }
    
        void AudioAssetChanged(AudioClip value)
        {
            audioSource.clip = value;
            audioSource.Play();
        }
    }

    Implements

    ISerializationCallbackReceiver
    In This Article
    • Implements
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)