123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using System;
- using UnityEngine;
- namespace I2.Loc
- {
- public class LocalizeTarget_UnityStandard_AudioSource : LocalizeTarget<AudioSource>
- {
- static LocalizeTarget_UnityStandard_AudioSource()
- {
- LocalizeTarget_UnityStandard_AudioSource.AutoRegister();
- }
- [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
- private static void AutoRegister()
- {
- LocalizationManager.RegisterTarget(new LocalizeTargetDesc_Type<AudioSource, LocalizeTarget_UnityStandard_AudioSource>
- {
- 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<AudioClip>(mainTranslation);
- if (clip != audioClip)
- {
- this.mTarget.clip = audioClip;
- }
- if (flag && this.mTarget.clip)
- {
- this.mTarget.Play();
- }
- }
- }
- }
|