LoopScrollRectMulti.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*using UnityEngine;
  2. using UnityEngine.Events;
  3. using UnityEngine.EventSystems;
  4. using System;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using ET;
  8. namespace UnityEngine.UI
  9. {
  10. public abstract class LoopScrollRectMulti : LoopScrollRectBase
  11. {
  12. [HideInInspector]
  13. [NonSerialized]
  14. public LoopScrollMultiDataSource dataSource = null;
  15. protected override void ProvideData(Transform transform, int index)
  16. {
  17. dataSource.ProvideData(transform, index);
  18. }
  19. // Multi Data Source cannot support TempPool
  20. protected override async ETTask<RectTransform> GetFromTempPool(int itemIdx)
  21. {
  22. RectTransform nextItem = (await prefabSource.GetObject(itemIdx)).transform as RectTransform;
  23. nextItem.transform.SetParent(m_Content, false);
  24. nextItem.gameObject.SetActive(true);
  25. ProvideData(nextItem, itemIdx);
  26. return nextItem;
  27. }
  28. protected override void ReturnToTempPool(bool fromStart, int count)
  29. {
  30. Debug.Assert(m_Content.childCount >= count);
  31. if (fromStart)
  32. {
  33. for (int i = count - 1; i >= 0; i--)
  34. {
  35. prefabSource.ReturnObject(m_Content.GetChild(i));
  36. }
  37. }
  38. else
  39. {
  40. int t = m_Content.childCount - count;
  41. for (int i = m_Content.childCount - 1; i >= t; i--)
  42. {
  43. prefabSource.ReturnObject(m_Content.GetChild(i));
  44. }
  45. }
  46. }
  47. protected override void ClearTempPool()
  48. {
  49. }
  50. }
  51. }*/