AvatarList.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class AvatarList : MonoBehaviour
  5. {
  6. public GameObject Avatar;
  7. public void Init()
  8. {
  9. if (this.transform.childCount <= 0)
  10. {
  11. NetWorkHeaders.GetUserAvater((aData) =>
  12. {
  13. for (int i = 0; i < aData["data"]["user"].Count; i++)
  14. {
  15. GameObject avatarobj = Instantiate(Avatar, transform) as GameObject;
  16. if (avatarobj)
  17. {
  18. AvatarToggle avatarToggle = avatarobj.transform.GetComponent<AvatarToggle>();
  19. if (avatarToggle)
  20. {
  21. avatarToggle.Init(aData["data"]["user"][i].ToString());
  22. NetWorkHeaders.Instance.getNetTexture(aData["data"]["user"][i].ToString(), null, (Texture tex) => {
  23. if (tex)
  24. {
  25. avatarToggle.Init(tex);
  26. }
  27. });
  28. }
  29. }
  30. }
  31. });
  32. }
  33. }
  34. }