ButtonUI.cs 730 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. public class ButtonUI : MonoBehaviour
  4. {
  5. public Image[] image;
  6. public int nowImage;
  7. public void ChangeImg(int i)
  8. {
  9. image[nowImage].gameObject.SetActive(false);
  10. image[i].gameObject.SetActive(true);
  11. nowImage = i;
  12. }
  13. public void Test()
  14. {
  15. Debug.Log("Test");
  16. }
  17. public void ShowObj(GameObject obj)
  18. {
  19. obj.SetActive(true);
  20. }
  21. public void HideObj(GameObject obj)
  22. {
  23. obj.SetActive(false);
  24. }
  25. public void ShowObjOrNot(GameObject obj)
  26. {
  27. if (obj.activeSelf)
  28. {
  29. obj.SetActive(false);
  30. }
  31. else
  32. {
  33. obj.SetActive(true);
  34. }
  35. }
  36. }