LocalizeTarget_UnityUI_RawImage.cs 1.5 KB

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