MainHomeBottomPanelVM.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. using FairyGUI;
  2. namespace FL.FGUI
  3. {
  4. public partial class MainHomeBottomPanelVM
  5. {
  6. /// <summary>
  7. /// 设置按钮的解锁状态
  8. /// 索引和BtnCtrl.selectedIndex一致
  9. /// </summary>
  10. /// <param name="btnIndex">BtnCtrl.selectedIndex</param>
  11. /// <param name="isUnlock"></param>
  12. /// <param name="unlockTips">已解锁时,可不用传</param>
  13. public void SetUnlockState(int btnIndex, bool isUnlock, string unlockTips = null)
  14. {
  15. var button = btnIndex switch
  16. {
  17. 1 => RoleBtn,
  18. 2 => PartnerBtn,
  19. 3 => EpigraphBtn,
  20. 4 => DungeonBtn,
  21. 5 => FarmBtn,
  22. 6 => BoxBtn,
  23. _ => null,
  24. };
  25. button.GetController("UnlockCtrl").selectedIndex = isUnlock ? 1 : 0;
  26. if (!isUnlock)
  27. {
  28. (button.GetChild("UnlockTxt") as GTextField).text = unlockTips;
  29. }
  30. }
  31. }
  32. }