ScrollHelper.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public static class ScrollHelper
  6. {
  7. private static float ScaleFactor;
  8. private static ScrollRect ScrollRect;
  9. private static LayoutGroup LayoutGroup;
  10. private static RectTransform RectTransform;
  11. public static void Locate(this ScrollRect scrollRect, float verticalPos, float horizontalPos)
  12. {
  13. Vector2 viewSize = scrollRect.viewport.rect.size;
  14. Vector2 contentSize = scrollRect.content.rect.size;
  15. if (viewSize.x >= contentSize.x && viewSize.y >= contentSize.y)
  16. {
  17. return;
  18. }
  19. }
  20. private static void Init(ScrollRect scrollRect)
  21. {
  22. ScaleFactor = scrollRect.GetComponentInChildren<Graphic>().canvas.scaleFactor;
  23. LayoutGroup = scrollRect.content.GetComponent<LayoutGroup>();
  24. RectTransform = scrollRect.GetComponent<RectTransform>();
  25. }
  26. private static void CalVertical(float normalizedPos)
  27. {
  28. }
  29. private static void CalHorizontal()
  30. {
  31. }
  32. }