LocalizeTarget_UnityStandard_SpriteRenderer.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using UnityEngine;
  3. namespace I2.Loc
  4. {
  5. public class LocalizeTarget_UnityStandard_SpriteRenderer : LocalizeTarget<SpriteRenderer>
  6. {
  7. static LocalizeTarget_UnityStandard_SpriteRenderer()
  8. {
  9. LocalizeTarget_UnityStandard_SpriteRenderer.AutoRegister();
  10. }
  11. [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
  12. private static void AutoRegister()
  13. {
  14. LocalizationManager.RegisterTarget(new LocalizeTargetDesc_Type<SpriteRenderer, LocalizeTarget_UnityStandard_SpriteRenderer>
  15. {
  16. Name = "SpriteRenderer",
  17. Priority = 100
  18. });
  19. }
  20. public override eTermType GetPrimaryTermType(Localize cmp)
  21. {
  22. return eTermType.Sprite;
  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.sprite != null)) ? string.Empty : this.mTarget.sprite.name);
  43. secondaryTerm = null;
  44. }
  45. public override void DoLocalize(Localize cmp, string mainTranslation, string secondaryTranslation)
  46. {
  47. Sprite sprite = this.mTarget.sprite;
  48. if (sprite == null || sprite.name != mainTranslation)
  49. {
  50. this.mTarget.sprite = cmp.FindTranslatedObject<Sprite>(mainTranslation);
  51. }
  52. }
  53. }
  54. }