ListViewerWindow.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections.Generic;
  3. using Kasizuki;
  4. using UnityEngine;
  5. using UnityEngine.Events;
  6. public class ListViewerWindow : NGUIWindow
  7. {
  8. public uGUIListViewer viewer
  9. {
  10. get
  11. {
  12. return this.m_ListViewer;
  13. }
  14. }
  15. public void Show<DataType, ItemType>(List<DataType> dataList, Action<int, DataType, ItemType> itemSetUp) where ItemType : Component
  16. {
  17. this.m_ListViewer.Show<ItemType>(dataList.Count, delegate(int index, ItemType item)
  18. {
  19. DataType arg = dataList[index];
  20. itemSetUp(index, arg, item);
  21. });
  22. this.Reposition();
  23. if (this.OnShow != null)
  24. {
  25. this.OnShow.Invoke();
  26. }
  27. }
  28. public void Reposition()
  29. {
  30. UIGrid uigrid = this.m_UIGrid;
  31. if (uigrid == null)
  32. {
  33. uigrid = this.m_ListViewer.parentItemArea.GetComponent<UIGrid>();
  34. }
  35. if (uigrid)
  36. {
  37. uigrid.Reposition();
  38. }
  39. UIScrollView uiscrollView = this.m_UIScrollView;
  40. if (uiscrollView == null)
  41. {
  42. uiscrollView = this.m_ListViewer.parentItemArea.GetComponentInParent<UIScrollView>();
  43. }
  44. if (uiscrollView)
  45. {
  46. uiscrollView.ResetPosition();
  47. }
  48. }
  49. [SerializeField]
  50. private uGUIListViewer m_ListViewer;
  51. [SerializeField]
  52. private UIGrid m_UIGrid;
  53. [SerializeField]
  54. private UIScrollView m_UIScrollView;
  55. public UnityEvent OnShow;
  56. }