FixScoresButtonsYPosition.cs 979 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using UnityEngine;
  2. using System.Collections;
  3. /// <summary>
  4. /// Fix scores buttons Y position for the Me/Top10/Facebook/Global buttons that are visible in the scores screen.
  5. /// Since we are using the same scores screen (and thus the buttons), we fix their positions accordingly.
  6. /// </summary>
  7. public class FixScoresButtonsYPosition : MonoBehaviour
  8. {
  9. const int POS_Y_BEFORE_GAME = 194;
  10. const int POS_Y_AFTER_GAME = 146;
  11. const int POS_Y_FOR_GLOBAL_LEADERBOARD = 50;
  12. void OnEnable()
  13. {
  14. switch (MenuManager.CurrentState)
  15. {
  16. case MenuManager.MenuState.ViewingScoresBeforeGame:
  17. FixYPosition(POS_Y_BEFORE_GAME);
  18. break;
  19. case MenuManager.MenuState.ViewingScoresAfterGame:
  20. FixYPosition(POS_Y_AFTER_GAME);
  21. break;
  22. case MenuManager.MenuState.ViewingGlobalLeaderboard:
  23. FixYPosition(POS_Y_FOR_GLOBAL_LEADERBOARD);
  24. break;
  25. }
  26. }
  27. void FixYPosition(int newY)
  28. {
  29. Vector3 p = transform.localPosition;
  30. p.y = newY;
  31. transform.localPosition = p;
  32. }
  33. }