CommentItem.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using Random = UnityEngine.Random;
  7. public class CommentItem : Regist
  8. {
  9. public Text Tit;
  10. public Text VisitLab;
  11. public Button VisitBtn;
  12. public BestfitText ContentLab;
  13. public string Content;
  14. public string SerialNumber;
  15. public override bool RegistImmed()
  16. {
  17. if (base.RegistImmed())
  18. {
  19. return true;
  20. }
  21. Dictionary<string, Transform> childDic = new Dictionary<string, Transform>();
  22. Auxiliary.CompileDic(transform, childDic);
  23. Tit = childDic["Tit"].GetComponent<Text>();
  24. VisitLab = childDic["VisitLab"].GetComponent<Text>();
  25. VisitBtn = childDic["VisitBtn"].GetComponent<Button>();
  26. ContentLab = childDic["ContentLab"].GetComponent<BestfitText>();
  27. ContentLab.VerticalMaxSize = 20;
  28. VisitLab.text = ManaReso.Get<Text>("C_CostLab").text;
  29. VisitBtn.onClick.AddListener(Visit);
  30. ManaCenter.OnLevelChange += () =>
  31. {
  32. VisitLab.text = ManaReso.Get<Text>("C_CostLab").text;
  33. };
  34. return false;
  35. }
  36. public void Visit()
  37. {
  38. ManaSocial.Record();
  39. ManaVisit.Visit(ArchiveSource.SerialNumber, SerialNumber);
  40. }
  41. public void Reset(string serialNumber, string content)
  42. {
  43. Content = content;
  44. SerialNumber = serialNumber;
  45. try
  46. {
  47. Tit.text = "****" + serialNumber.Substring(serialNumber.Length - 4);
  48. }
  49. catch (Exception)
  50. {
  51. Tit.text = "****" + Random.Range(1000, 10000);
  52. Debug.LogWarning("Error " + serialNumber);
  53. }
  54. ContentLab.text = content;
  55. }
  56. }