B08_TaskListItem.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class B08_TaskListItem : MonoBehaviour
  6. {
  7. public Text typeText;
  8. public Text titleText;
  9. public Text stateText;
  10. public Text dateText;
  11. public Text ctrlText;
  12. public GameObject more;
  13. public Button moreButton;
  14. public bool moreMessage = false;
  15. public RectTransform rect;
  16. public void Init()
  17. {
  18. rect = this.GetComponent<RectTransform>();
  19. typeText = this.transform.Find("typeText").GetComponent<Text>();
  20. titleText = this.transform.Find("titleText").GetComponent<Text>();
  21. stateText = this.transform.Find("stateText").GetComponent<Text>();
  22. dateText = this.transform.Find("dateText").GetComponent<Text>();
  23. ctrlText = this.transform.Find("ctrlText").GetComponent<Text>();
  24. more = this.transform.Find("more").gameObject;
  25. more.SetActive(false);
  26. moreButton = ctrlText.GetComponent<Button>();
  27. moreButton.onClick.AddListener(ChangeMoreMessage);
  28. }
  29. public void ChangeMoreMessage()
  30. {
  31. if (moreMessage)
  32. {
  33. ctrlText.text = "详情";
  34. rect.sizeDelta = new Vector2(360,38);
  35. more.SetActive(false);
  36. }
  37. else
  38. {
  39. ctrlText.text = "收起";
  40. rect.sizeDelta = new Vector2(360,254);
  41. more.SetActive(true);
  42. }
  43. moreMessage = !moreMessage;
  44. }
  45. }