UIWarpContentItem.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using UnityEngine;
  2. using System.Collections;
  3. /// <summary>
  4. /// warp下Element对应标记
  5. /// </summary>
  6. [DisallowMultipleComponent]
  7. public class UIWarpContentItem : MonoBehaviour
  8. {
  9. /// <summary>
  10. /// 数据索引
  11. /// </summary>
  12. private int index = -1;
  13. /// <summary>
  14. /// 元素列表优化
  15. /// </summary>
  16. private UIWarpContent warpContent = null;
  17. /// <summary>
  18. /// 销毁
  19. /// </summary>
  20. private void OnDestroy()
  21. {
  22. warpContent = null;
  23. }
  24. /// <summary>
  25. /// 元素列表优化对象
  26. /// </summary>
  27. public UIWarpContent WarpContent
  28. {
  29. set
  30. {
  31. warpContent = value;
  32. }
  33. }
  34. /// <summary>
  35. /// 数据索引
  36. /// </summary>
  37. public int Index
  38. {
  39. get
  40. {
  41. return index;
  42. }
  43. set
  44. {
  45. index = value;
  46. transform.localPosition = warpContent.getLocalPositionByIndex(index);
  47. gameObject.name = (index < 10) ? ("0" + index) : (string.Empty + index);
  48. if (warpContent.onInitializeItem != null && index >= 0)
  49. {
  50. warpContent.onInitializeItem(gameObject, index);
  51. }
  52. }
  53. }
  54. }