RankComp.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Api;
  5. using Plugins.CxShine.UIUtil;
  6. using UI.Items;
  7. using UnityEngine.Rendering;
  8. using UnityEngine.UI;
  9. public class RankComp : MonoBehaviour
  10. {
  11. public Image india;
  12. public Image all;
  13. public Sprite selectSp;
  14. public Sprite unSelectSp;
  15. public GameObject RankItemPrefab;
  16. public Transform RankItemContainer;
  17. private bool isIndia = true;
  18. // Start is called before the first frame update
  19. void Start()
  20. {
  21. refreshUI();
  22. }
  23. private void refreshUI()
  24. {
  25. india.sprite = isIndia ? selectSp : unSelectSp;
  26. all.sprite = !isIndia ? selectSp : unSelectSp;
  27. ContainerUtil.RemoveAllChild(this,RankItemContainer);
  28. ApiComp.Instance.playerRank(isIndia, data =>
  29. {
  30. for (int i = 0; i < data.rankList.Count; i++)
  31. {
  32. var go = Instantiate(RankItemPrefab, RankItemContainer);
  33. var comp = go.GetComponent<RankItemComp>();
  34. comp.init(id=>{},data.rankList[i],i+1);
  35. }
  36. }, (code, err) =>
  37. {
  38. });
  39. }
  40. public void A__ClickIndia()
  41. {
  42. if (isIndia)
  43. {
  44. return;
  45. }
  46. isIndia =true;
  47. refreshUI();
  48. }
  49. public void A__ClickAll()
  50. {
  51. if (!isIndia)
  52. {
  53. return;
  54. }
  55. isIndia =false;
  56. refreshUI();
  57. }
  58. }