using System; using UnityEngine; namespace I2.Loc { public class LocalizeTarget_NGUI_Sprite : LocalizeTarget { static LocalizeTarget_NGUI_Sprite() { LocalizeTarget_NGUI_Sprite.AutoRegister(); } [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] private static void AutoRegister() { LocalizationManager.RegisterTarget(new LocalizeTargetDesc_Type { Name = "NGUI UISprite", Priority = 100 }); } public override eTermType GetPrimaryTermType(Localize cmp) { return eTermType.Sprite; } public override eTermType GetSecondaryTermType(Localize cmp) { return eTermType.UIAtlas; } public override bool CanUseSecondaryTerm() { return true; } 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) ? null : this.mTarget.spriteName); secondaryTerm = ((!(this.mTarget.atlas != null)) ? string.Empty : this.mTarget.atlas.name); } public override void DoLocalize(Localize cmp, string mainTranslation, string secondaryTranslation) { if (this.mTarget.spriteName == mainTranslation) { return; } UIAtlas secondaryTranslatedObj = cmp.GetSecondaryTranslatedObj(ref mainTranslation, ref secondaryTranslation); bool flag = false; if (secondaryTranslatedObj != null && this.mTarget.atlas != secondaryTranslatedObj) { this.mTarget.atlas = secondaryTranslatedObj; flag = true; } if (this.mTarget.spriteName != mainTranslation && this.mTarget.atlas.GetSprite(mainTranslation) != null) { this.mTarget.spriteName = mainTranslation; flag = true; } if (flag && !cmp.NotAdjustScale) { this.mTarget.MakePixelPerfect(); } } } }