PhotSaveLoagDataUnit.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. using System;
  2. using UnityEngine;
  3. public class PhotSaveLoagDataUnit : MonoBehaviour
  4. {
  5. public string title
  6. {
  7. get
  8. {
  9. return this.title_input_.value;
  10. }
  11. set
  12. {
  13. this.title_input_.value = value;
  14. }
  15. }
  16. public string comment
  17. {
  18. get
  19. {
  20. return this.comment_input_.value;
  21. }
  22. set
  23. {
  24. this.comment_input_.value = value;
  25. }
  26. }
  27. public string date_text
  28. {
  29. get
  30. {
  31. return this.data_label_.text;
  32. }
  33. set
  34. {
  35. this.data_label_.text = value;
  36. }
  37. }
  38. public int maid_count
  39. {
  40. get
  41. {
  42. return int.Parse(this.maid_count_label_.text);
  43. }
  44. set
  45. {
  46. this.maid_count_label_.text = value.ToString("d2");
  47. }
  48. }
  49. public bool new_sloat
  50. {
  51. get
  52. {
  53. return this.new_sprite_object_.activeSelf;
  54. }
  55. set
  56. {
  57. this.new_sprite_object_.SetActive(value);
  58. }
  59. }
  60. public bool visible_content
  61. {
  62. get
  63. {
  64. return this.data_info_obj_.activeSelf;
  65. }
  66. set
  67. {
  68. this.RemoveInputFocus();
  69. this.data_info_obj_.SetActive(value);
  70. }
  71. }
  72. public bool enabled_button
  73. {
  74. get
  75. {
  76. return this.main_btn_.isEnabled;
  77. }
  78. set
  79. {
  80. this.RemoveInputFocus();
  81. this.main_btn_.isEnabled = value;
  82. }
  83. }
  84. public object save_data_object
  85. {
  86. get
  87. {
  88. return this.save_data_object_;
  89. }
  90. set
  91. {
  92. this.save_data_object_ = value;
  93. }
  94. }
  95. public byte[] thumbnail
  96. {
  97. set
  98. {
  99. if (value == null || value.Length <= 0)
  100. {
  101. if (this.thumbnail_sprite_.sprite2D != null && this.thumbnail_sprite_.sprite2D.texture != null)
  102. {
  103. UnityEngine.Object.DestroyImmediate(this.thumbnail_sprite_.sprite2D.texture);
  104. }
  105. this.thumbnail_sprite_.sprite2D = null;
  106. return;
  107. }
  108. Texture2D texture2D = new Texture2D(1, 1, TextureFormat.ARGB32, false);
  109. texture2D.LoadImage(value);
  110. Sprite sprite2D = Sprite.Create(texture2D, new Rect(0f, 0f, (float)texture2D.width, (float)texture2D.height), default(Vector2));
  111. if (this.thumbnail_sprite_.sprite2D != null && this.thumbnail_sprite_.sprite2D.texture != null)
  112. {
  113. UnityEngine.Object.DestroyImmediate(this.thumbnail_sprite_.sprite2D.texture);
  114. }
  115. this.thumbnail_sprite_.sprite2D = sprite2D;
  116. this.thumbnail_sprite_.SetDimensions(texture2D.width, texture2D.height);
  117. }
  118. }
  119. public Texture2D thumbnail_tex
  120. {
  121. set
  122. {
  123. if (value == null)
  124. {
  125. if (this.thumbnail_sprite_.sprite2D != null && this.thumbnail_sprite_.sprite2D.texture != null)
  126. {
  127. UnityEngine.Object.DestroyImmediate(this.thumbnail_sprite_.sprite2D.texture);
  128. }
  129. this.thumbnail_sprite_.sprite2D = null;
  130. return;
  131. }
  132. Sprite sprite2D = Sprite.Create(value, new Rect(0f, 0f, (float)value.width, (float)value.height), default(Vector2));
  133. if (this.thumbnail_sprite_.sprite2D != null && this.thumbnail_sprite_.sprite2D.texture != null)
  134. {
  135. UnityEngine.Object.DestroyImmediate(this.thumbnail_sprite_.sprite2D.texture);
  136. }
  137. this.thumbnail_sprite_.sprite2D = sprite2D;
  138. this.thumbnail_sprite_.SetDimensions(value.width, value.height);
  139. }
  140. }
  141. public void Awake()
  142. {
  143. this.main_btn_ = base.GetComponent<UIButton>();
  144. EventDelegate.Add(this.main_btn_.onClick, new EventDelegate.Callback(this.OnClickEvent));
  145. this.data_info_obj_ = UTY.GetChildObject(base.gameObject, "Content/DataInfo", false);
  146. this.title_input_ = UTY.GetChildObject(this.data_info_obj_, "Title/InputField", false).GetComponent<UIInput>();
  147. EventDelegate.Add(this.title_input_.onChange, new EventDelegate.Callback(this.OnChangeTitle));
  148. this.comment_input_ = UTY.GetChildObject(this.data_info_obj_, "Comment/InputField", false).GetComponent<UIInput>();
  149. EventDelegate.Add(this.comment_input_.onChange, new EventDelegate.Callback(this.OnChangeComment));
  150. this.data_label_ = UTY.GetChildObject(this.data_info_obj_, "Date", false).GetComponent<UILabel>();
  151. this.maid_count_label_ = UTY.GetChildObject(this.data_info_obj_, "NumberOfEmployees/Number", false).GetComponent<UILabel>();
  152. this.new_sprite_object_ = UTY.GetChildObject(this.data_info_obj_, "NewLabel", false);
  153. this.new_sprite_object_.SetActive(false);
  154. this.thumbnail_sprite_ = UTY.GetChildObject(this.data_info_obj_, "Thum", false).GetComponent<UI2DSprite>();
  155. string empty = string.Empty;
  156. this.comment = empty;
  157. this.title = empty;
  158. this.maid_count = 0;
  159. }
  160. public void OnDestroy()
  161. {
  162. if (this.thumbnail_sprite_ != null && this.thumbnail_sprite_.sprite2D != null && this.thumbnail_sprite_.sprite2D.texture != null)
  163. {
  164. UnityEngine.Object.DestroyImmediate(this.thumbnail_sprite_.sprite2D.texture);
  165. }
  166. this.thumbnail_sprite_.sprite2D = null;
  167. }
  168. public void RemoveInputFocus()
  169. {
  170. this.title_input_.RemoveFocus();
  171. this.comment_input_.RemoveFocus();
  172. }
  173. private void OnChangeTitle()
  174. {
  175. if (this.onChangeTitle != null)
  176. {
  177. this.onChangeTitle(this);
  178. }
  179. }
  180. private void OnChangeComment()
  181. {
  182. if (this.onChangeComment != null)
  183. {
  184. this.onChangeComment(this);
  185. }
  186. }
  187. private void OnClickEvent()
  188. {
  189. if (this.onClick != null)
  190. {
  191. this.onClick(this);
  192. }
  193. }
  194. public Action<PhotSaveLoagDataUnit> onClick;
  195. public Action<PhotSaveLoagDataUnit> onChangeTitle;
  196. public Action<PhotSaveLoagDataUnit> onChangeComment;
  197. private UIButton main_btn_;
  198. private GameObject data_info_obj_;
  199. private UIInput title_input_;
  200. private UIInput comment_input_;
  201. private UILabel data_label_;
  202. private UILabel maid_count_label_;
  203. private GameObject new_sprite_object_;
  204. private UI2DSprite thumbnail_sprite_;
  205. private object save_data_object_;
  206. }