MenuSelectEffect.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class MenuSelectEffect : MonoBehaviour
  6. {
  7. public Text MenuTitle;
  8. Color32 oldColor = Color.white;
  9. Color32 ColorModeSelected = new Color32(255, 225, 64, 217);
  10. private void OnEnable() {
  11. // Change the color and content of the button in MenuGUI
  12. if(MenuTitle!=null){
  13. oldColor = MenuTitle.color;
  14. MenuTitle.color = ColorModeSelected;
  15. MenuTitle.fontStyle = FontStyle.Bold;
  16. MenuTitle.text = MenuTitle.text + " (Now)";
  17. }
  18. }
  19. // Start is called before the first frame update
  20. void Start()
  21. {
  22. }
  23. // Update is called once per frame
  24. void Update()
  25. {
  26. }
  27. private void OnDisable() {
  28. // Recover the color and content of Button in MenuGUI
  29. if(MenuTitle!=null){
  30. MenuTitle.color = oldColor;
  31. MenuTitle.fontStyle = FontStyle.Normal;
  32. MenuTitle.text = gameObject.name;
  33. }
  34. }
  35. }