using System; using UnityEngine; namespace I2.Loc { public class LocalizeTarget_UnityStandard_AudioSource : LocalizeTarget { static LocalizeTarget_UnityStandard_AudioSource() { LocalizeTarget_UnityStandard_AudioSource.AutoRegister(); } [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] private static void AutoRegister() { LocalizationManager.RegisterTarget(new LocalizeTargetDesc_Type { Name = "AudioSource", Priority = 100 }); } public override eTermType GetPrimaryTermType(Localize cmp) { return eTermType.AudioClip; } public override eTermType GetSecondaryTermType(Localize cmp) { return eTermType.Text; } public override bool CanUseSecondaryTerm() { return false; } public override bool AllowMainTermToBeRTL() { return false; } public override bool AllowSecondTermToBeRTL() { return false; } public override void GetFinalTerms(Localize cmp, string Main, string Secondary, out string primaryTerm, out string secondaryTerm) { primaryTerm = ((!this.mTarget.clip) ? string.Empty : this.mTarget.clip.name); secondaryTerm = null; } public override void DoLocalize(Localize cmp, string mainTranslation, string secondaryTranslation) { bool flag = (this.mTarget.isPlaying || this.mTarget.loop) && Application.isPlaying; AudioClip clip = this.mTarget.clip; AudioClip audioClip = cmp.FindTranslatedObject(mainTranslation); if (clip != audioClip) { this.mTarget.clip = audioClip; } if (flag && this.mTarget.clip) { this.mTarget.Play(); } } } }