NGUILabelSpacingHold.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System;
  2. using I2.Loc;
  3. using UnityEngine;
  4. using UnityEngine.Events;
  5. [RequireComponent(typeof(Localize))]
  6. [RequireComponent(typeof(UILabel))]
  7. public class NGUILabelSpacingHold : MonoBehaviour
  8. {
  9. private void Awake()
  10. {
  11. if (this.callAwake)
  12. {
  13. return;
  14. }
  15. this.callAwake = true;
  16. this.localize = base.GetComponent<Localize>();
  17. this.label = base.GetComponent<UILabel>();
  18. if (this.localize != null && this.label != null)
  19. {
  20. this.localize.LocalizeEvent.AddListener(new UnityAction(this.OnLocalize));
  21. if (this.label.useFloatSpacing)
  22. {
  23. this.HoldSpacingX = this.label.floatSpacingX;
  24. this.HoldSpacingY = this.label.floatSpacingY;
  25. }
  26. else
  27. {
  28. this.HoldSpacingX = (float)this.label.spacingX;
  29. this.HoldSpacingY = (float)this.label.spacingY;
  30. }
  31. this.updateReq = true;
  32. this.OnLocalize();
  33. }
  34. }
  35. public void OnLocalize()
  36. {
  37. if (!this.callAwake)
  38. {
  39. this.Awake();
  40. }
  41. if (!this.updateReq)
  42. {
  43. return;
  44. }
  45. if (LocalizationManager.CurrentLanguageCode == "ja")
  46. {
  47. if (this.label.useFloatSpacing)
  48. {
  49. this.label.floatSpacingX = this.HoldSpacingX;
  50. this.label.floatSpacingY = this.HoldSpacingY;
  51. }
  52. else
  53. {
  54. this.label.spacingX = (int)this.HoldSpacingX;
  55. this.label.spacingY = (int)this.HoldSpacingY;
  56. }
  57. }
  58. else if (this.label.useFloatSpacing)
  59. {
  60. UILabel uilabel = this.label;
  61. float num = 0f;
  62. this.label.floatSpacingY = num;
  63. uilabel.floatSpacingX = num;
  64. }
  65. else
  66. {
  67. UILabel uilabel2 = this.label;
  68. int num2 = 0;
  69. this.label.spacingY = num2;
  70. uilabel2.spacingX = num2;
  71. }
  72. }
  73. private float HoldSpacingX;
  74. private float HoldSpacingY;
  75. private bool updateReq;
  76. private bool callAwake;
  77. private Localize localize;
  78. private UILabel label;
  79. }