LocalizeTarget_NGUI_Texture.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System;
  2. using UnityEngine;
  3. namespace I2.Loc
  4. {
  5. public class LocalizeTarget_NGUI_Texture : LocalizeTarget<UITexture>
  6. {
  7. static LocalizeTarget_NGUI_Texture()
  8. {
  9. LocalizeTarget_NGUI_Texture.AutoRegister();
  10. }
  11. [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
  12. private static void AutoRegister()
  13. {
  14. LocalizationManager.RegisterTarget(new LocalizeTargetDesc_Type<UITexture, LocalizeTarget_NGUI_Texture>
  15. {
  16. Name = "NGUI UITexture",
  17. Priority = 100
  18. });
  19. }
  20. public override eTermType GetPrimaryTermType(Localize cmp)
  21. {
  22. return eTermType.Texture;
  23. }
  24. public override eTermType GetSecondaryTermType(Localize cmp)
  25. {
  26. return eTermType.Text;
  27. }
  28. public override bool CanUseSecondaryTerm()
  29. {
  30. return false;
  31. }
  32. public override bool AllowMainTermToBeRTL()
  33. {
  34. return false;
  35. }
  36. public override bool AllowSecondTermToBeRTL()
  37. {
  38. return false;
  39. }
  40. public override void GetFinalTerms(Localize cmp, string Main, string Secondary, out string primaryTerm, out string secondaryTerm)
  41. {
  42. primaryTerm = ((!(this.mTarget != null) || !(this.mTarget.mainTexture != null)) ? null : this.mTarget.mainTexture.name);
  43. secondaryTerm = null;
  44. }
  45. public override void DoLocalize(Localize cmp, string mainTranslation, string secondaryTranslation)
  46. {
  47. Texture mainTexture = this.mTarget.mainTexture;
  48. if (mainTexture == null || mainTexture.name != mainTranslation)
  49. {
  50. this.mTarget.mainTexture = cmp.FindTranslatedObject<Texture>(mainTranslation);
  51. this.mTarget.MakePixelPerfect();
  52. }
  53. }
  54. }
  55. }