CommentItem.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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.CloseCommentPanel();
  39. ManaSocial.RecordCommentPanel();
  40. ManaVisit.Visit(ArchiveSource.SerialNumber, SerialNumber);
  41. }
  42. public void Reset(string serialNumber, string content)
  43. {
  44. Content = content;
  45. SerialNumber = serialNumber;
  46. try
  47. {
  48. Tit.text = "****" + serialNumber.Substring(serialNumber.Length - 4);
  49. }
  50. catch (Exception)
  51. {
  52. Tit.text = "****" + Random.Range(1000, 10000);
  53. Debug.LogWarning("Error " + serialNumber);
  54. }
  55. ContentLab.text = content;
  56. }
  57. }