123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using System;
- using UnityEngine;
- namespace I2.Loc
- {
- public class LocalizeTarget_NGUI_Sprite : LocalizeTarget<UISprite>
- {
- static LocalizeTarget_NGUI_Sprite()
- {
- LocalizeTarget_NGUI_Sprite.AutoRegister();
- }
- [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
- private static void AutoRegister()
- {
- LocalizationManager.RegisterTarget(new LocalizeTargetDesc_Type<UISprite, LocalizeTarget_NGUI_Sprite>
- {
- 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<UIAtlas>(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();
- }
- }
- }
- }
|