AttributeViewer.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using MaidStatus;
  4. using UnityEngine;
  5. public class AttributeViewer : MonoBehaviour
  6. {
  7. public void Awake()
  8. {
  9. if (this.seiheki_table_ != null)
  10. {
  11. return;
  12. }
  13. this.updateStatusInfo = false;
  14. this.seiheki_table_ = UTY.GetChildObject(base.gameObject, "Contents/Attribute/AttributeUnitParent", false).GetComponent<UITable>();
  15. List<Transform> childList = this.seiheki_table_.GetChildList();
  16. for (int i = 0; i < childList.Count; i++)
  17. {
  18. childList[i].gameObject.SetActive(false);
  19. }
  20. this.seiheki_table_.Reposition();
  21. }
  22. public void OnEnable()
  23. {
  24. this.UpdateStatusInfo();
  25. }
  26. public void UpdateStatusInfo()
  27. {
  28. this.Awake();
  29. if (this.updateStatusInfo || this.targetMaid == null)
  30. {
  31. return;
  32. }
  33. this.updateStatusInfo = true;
  34. Status status = this.targetMaid.status;
  35. List<Transform> childList = this.seiheki_table_.GetChildList();
  36. for (int i = 0; i < childList.Count; i++)
  37. {
  38. childList[i].gameObject.SetActive(false);
  39. }
  40. int num = 0;
  41. foreach (Propensity.Data data in status.propensitys.GetValueArray())
  42. {
  43. if (childList.Count <= num)
  44. {
  45. break;
  46. }
  47. childList[num].gameObject.SetActive(true);
  48. UILabel componentInChildren = childList[num].gameObject.GetComponentInChildren<UILabel>();
  49. if (!(componentInChildren == null))
  50. {
  51. componentInChildren.text = data.drawName;
  52. num++;
  53. }
  54. }
  55. }
  56. [SerializeField]
  57. public Maid targetMaid;
  58. private UITable seiheki_table_;
  59. private bool updateStatusInfo;
  60. }