OnlineGamesPanelUI.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5. using UnityEngine.UI;
  6. public class OnlineGamesPanelUI : GamesScrollController {
  7. private RectTransform[] parents;
  8. private RectTransform OnlineGamesPanelRectTransform;
  9. private RectTransform titleRect;
  10. private Image img;
  11. private RectTransform finishedGamesRT;
  12. private ScrollRect scrollRect;
  13. private void Start() {
  14. parents = GetComponentsInParent<RectTransform>();
  15. OnlineGamesPanelRectTransform = parents[1];
  16. titleRect = gameObject.GetComponent<RectTransform>();
  17. img = gameObject.GetComponentInChildren<Image>();
  18. finishedGamesRT = GameObject.Find("FinishedGamesPanel").GetComponent<RectTransform>();
  19. scrollRect = OnlineGamesPanelRectTransform.GetComponentInChildren<ScrollRect>();
  20. if (OnlineGamesPanelRectTransform.rect.height != titleRect.rect.height) {
  21. img.sprite = downArrow;
  22. } else {
  23. img.sprite = upArrow;
  24. }
  25. }
  26. /*
  27. public void OnPointerClick(PointerEventData eventData) {
  28. // Check if parent is expanded, if so minimize else maximize
  29. float finishedGamesPanelHeight = finishedGamesRT.rect.height;
  30. if (OnlineGamesPanelRectTransform.rect.height != titleRect.rect.height) {
  31. minimize();
  32. } else {
  33. // Maximera
  34. if (finishedGamesRT.GetComponentInChildren<finishedGamesUI>().Expanded) {
  35. OnlineGamesPanelRectTransform.sizeDelta = new Vector2(OnlineGamesPanelRectTransform.rect.width, GamesPanel.GetComponent<RectTransform>().rect.height - finishedGamesPanelHeight);
  36. } else {
  37. OnlineGamesPanelRectTransform.sizeDelta = new Vector2(OnlineGamesPanelRectTransform.rect.width, GamesPanel.GetComponent<RectTransform>().rect.height - finishedGamesPanelHeight);
  38. }
  39. scrollRect.enabled = true;
  40. img.sprite = downArrow;
  41. Expanded = true;
  42. }
  43. }
  44. */
  45. }