UIToggleImageSet.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. namespace Fort23.Mono
  4. {
  5. public class UIToggleImageSet : UIToggleWidgetBasic
  6. {
  7. public bool isNoSize;
  8. public MyImage[] alterIamge;
  9. public string[] showName;
  10. public string[] hindName;
  11. public Text[] alterText;
  12. public Color[] showColors;
  13. public Color[] hindColors;
  14. public int[] showSize;
  15. public int[] hindSize;
  16. public override void Show()
  17. {
  18. for (int i = 0; i < alterIamge.Length; i++)
  19. {
  20. alterIamge[i].icon_name = showName[i];
  21. alterIamge[i].enabled = true;
  22. if (!isNoSize)
  23. {
  24. alterIamge[i].SetNativeSize();
  25. }
  26. }
  27. for (int i = 0; i < alterText.Length; i++)
  28. {
  29. alterText[i].color = showColors[i];
  30. if (showSize.Length > i)
  31. {
  32. alterText[i].fontSize = showSize[i];
  33. }
  34. }
  35. }
  36. public override void Hind()
  37. {
  38. for (int i = 0; i < alterIamge.Length; i++)
  39. {
  40. if (hindName.Length <= i)
  41. {
  42. alterIamge[i].enabled = false;
  43. }
  44. else
  45. {
  46. alterIamge[i].icon_name = hindName[i];
  47. if (!isNoSize)
  48. {
  49. alterIamge[i].SetNativeSize();
  50. }
  51. }
  52. }
  53. for (int i = 0; i < alterText.Length; i++)
  54. {
  55. alterText[i].color = hindColors[i];
  56. if (showSize.Length > i)
  57. {
  58. alterText[i].fontSize = showSize[i];
  59. }
  60. }
  61. }
  62. }
  63. }