TabButton.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using Sirenix.OdinInspector;
  6. using KairoEngine.UI.InteractionHandler;
  7. namespace KairoEngine.UI
  8. {
  9. [HideMonoScript]
  10. public class TabButton : MonoBehaviour
  11. {
  12. public Button targetButton;
  13. public Sprite buttonGraphic;
  14. public Sprite buttonActiveGraphic;
  15. private bool active = false;
  16. public void SwitchState()
  17. {
  18. if(active)
  19. {
  20. active = false;
  21. targetButton.image.sprite = buttonGraphic;
  22. }
  23. else
  24. {
  25. active = true;
  26. targetButton.image.sprite = buttonActiveGraphic;
  27. }
  28. }
  29. public void Activate()
  30. {
  31. active = true;
  32. targetButton.image.sprite = buttonActiveGraphic;
  33. }
  34. public void Deactivate()
  35. {
  36. active = false;
  37. targetButton.image.sprite = buttonGraphic;
  38. }
  39. }
  40. }