UserList.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using XRTool.Util;
  5. public class UserList : UnitySingleton<UserList>
  6. {
  7. public GameObject Item;
  8. public void Init(List<InviteUserConfig> inviteUserConfigList)
  9. {
  10. if (transform.childCount > 0)
  11. {
  12. for (int i = 0; i < transform.childCount; i++)
  13. {
  14. Destroy(transform.GetChild(i).gameObject);
  15. }
  16. }
  17. AddItem(inviteUserConfigList);
  18. }
  19. private void AddItem(List<InviteUserConfig> inviteUserConfigList)
  20. {
  21. for (int i = 0; i < inviteUserConfigList.Count; i++)
  22. {
  23. GameObject obj = Instantiate(Item, transform) as GameObject;
  24. obj.transform.GetComponent<UserItem>().Init(inviteUserConfigList[i]);
  25. }
  26. }
  27. public void DestoryAll()
  28. {
  29. if (transform.childCount > 0)
  30. {
  31. for (int i = 0; i < transform.childCount; i++)
  32. {
  33. Destroy(transform.GetChild(i).gameObject);
  34. }
  35. }
  36. }
  37. }