From 10fac8d2941aecc45e980e99118c03106d90f240 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Thu, 9 May 2019 21:56:20 -0500 Subject: [PATCH] Switched to using ScrollView instead of ScrollRect to better integrate with BS UI --- .../UI/ViewControllers/MarkdownView.cs | 166 +++++++++++------- 1 file changed, 105 insertions(+), 61 deletions(-) diff --git a/BSIPA-ModList/UI/ViewControllers/MarkdownView.cs b/BSIPA-ModList/UI/ViewControllers/MarkdownView.cs index 4f60c105..c7c74ead 100644 --- a/BSIPA-ModList/UI/ViewControllers/MarkdownView.cs +++ b/BSIPA-ModList/UI/ViewControllers/MarkdownView.cs @@ -9,10 +9,11 @@ using CommonMark.Syntax; using UnityEngine.UI; using TMPro; using CustomUI.BeatSaber; +using IPA.Utilities; namespace BSIPA_ModList.UI.ViewControllers { - [RequireComponent(typeof(RectTransform), typeof(ScrollRect))] + [RequireComponent(typeof(RectTransform))] public class MarkdownView : MonoBehaviour { private class TagTypeComponent : MonoBehaviour @@ -35,10 +36,9 @@ namespace BSIPA_ModList.UI.ViewControllers public RectTransform rectTransform => GetComponent(); - private ScrollRect view; + private ScrollView scrView; private RectTransform content; private RectTransform viewport; - private Scrollbar scrollbar; private CommonMarkSettings settings; public MarkdownView() @@ -72,7 +72,7 @@ namespace BSIPA_ModList.UI.ViewControllers protected void Awake() { - view = GetComponent(); + /*view = GetComponent(); view.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHide; view.vertical = true; view.horizontal = false; @@ -84,7 +84,9 @@ namespace BSIPA_ModList.UI.ViewControllers scrollbar.transform.SetParent(transform); scrollbar.direction = Scrollbar.Direction.TopToBottom; scrollbar.interactable = true; - view.verticalScrollbar = scrollbar; + view.verticalScrollbar = scrollbar;*/ + + gameObject.SetActive(false); var vpgo = new GameObject("Viewport"); viewport = vpgo.AddComponent(); @@ -101,7 +103,7 @@ namespace BSIPA_ModList.UI.ViewControllers vpim.sprite = WhitePixel; vpim.material = CustomUI.Utilities.UIUtilities.NoGlowMaterial; - view.viewport = viewport; + //view.viewport = viewport; content = new GameObject("Content Wrapper").AddComponent(); content.SetParent(viewport); @@ -117,7 +119,37 @@ namespace BSIPA_ModList.UI.ViewControllers content.anchoredPosition = Vector2.zero; //content.sizeDelta = Vector2.zero; - view.content = content; + //view.content = content; + + var pageUp = Instantiate(Resources.FindObjectsOfTypeAll