NPCEditPlate.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using System;
  2. using UnityEngine;
  3. namespace SceneNPCEdit
  4. {
  5. public class NPCEditPlate : MonoBehaviour
  6. {
  7. public string lastName
  8. {
  9. get
  10. {
  11. return this.labelLastName.text;
  12. }
  13. set
  14. {
  15. this.labelLastName.text = value;
  16. }
  17. }
  18. public string firstName
  19. {
  20. get
  21. {
  22. return this.labelFirstName.text;
  23. }
  24. set
  25. {
  26. this.labelFirstName.text = value;
  27. }
  28. }
  29. public Texture2D thumbnail
  30. {
  31. get
  32. {
  33. return this.GetThumTex();
  34. }
  35. set
  36. {
  37. this.SetThumTex(value);
  38. }
  39. }
  40. public Sprite thumbnailSprite
  41. {
  42. get
  43. {
  44. return this.thumSprite.sprite2D;
  45. }
  46. }
  47. private void Awake()
  48. {
  49. UnityEngine.Object.Destroy(UTY.GetChildObject(base.gameObject, "Button", false).GetComponent<UIWFSelectButton>());
  50. UIWFTabButton component = UTY.GetChildObject(base.gameObject, "Button", false).GetComponent<UIWFTabButton>();
  51. if (component != null)
  52. {
  53. component.enabled = true;
  54. EventDelegate.Add(component.onSelect, new EventDelegate.Callback(this.OnSelectPlate));
  55. }
  56. UTY.GetChildObject(base.gameObject, "LeftPlate/FrameBaseData/FixText2", false).SetActive(false);
  57. UTY.GetChildObject(base.gameObject, "LeftPlate/FrameBaseData/TextTypeName", false).SetActive(false);
  58. this.labelLastName = UTY.GetChildObject(base.gameObject, "LeftPlate/FrameBaseData/TextLastName", false).GetComponent<UILabel>();
  59. this.labelFirstName = UTY.GetChildObject(base.gameObject, "LeftPlate/FrameBaseData/TextFirstName", false).GetComponent<UILabel>();
  60. this.thumSprite = UTY.GetChildObject(base.gameObject, "LeftPlate/FrameThumbnail/Thum", false).GetComponent<UI2DSprite>();
  61. }
  62. private void SetThumTex(Texture2D tex)
  63. {
  64. if (tex != null)
  65. {
  66. if (this.thumSprite.sprite2D == null || this.thumSprite.sprite2D.texture != tex)
  67. {
  68. Sprite sprite2D = Sprite.Create(tex, new Rect(0f, 0f, (float)tex.width, (float)tex.height), default(Vector2));
  69. this.thumSprite.sprite2D = sprite2D;
  70. this.thumSprite.SetDimensions(61, 88);
  71. }
  72. }
  73. else
  74. {
  75. this.thumSprite.sprite2D = null;
  76. }
  77. }
  78. private Texture2D GetThumTex()
  79. {
  80. return (!(this.thumSprite.sprite2D != null)) ? null : this.thumSprite.sprite2D.texture;
  81. }
  82. private void OnSelectPlate()
  83. {
  84. if (!UIWFSelectButton.current.isSelected)
  85. {
  86. return;
  87. }
  88. if (this.onSelectEvent != null)
  89. {
  90. this.onSelectEvent(this);
  91. }
  92. }
  93. public Action<NPCEditPlate> onSelectEvent;
  94. private UILabel labelLastName;
  95. private UILabel labelFirstName;
  96. private UI2DSprite thumSprite;
  97. }
  98. }