From 8404ca0947f0f88d500f72622a44b449ee9e692b Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Fri, 10 May 2019 16:31:23 -0500 Subject: [PATCH] Fixed scroll content position --- .../UI/ViewControllers/MarkdownView.cs | 65 +++++++++---------- BSIPA-ModList/manifest.json | 24 ------- 2 files changed, 29 insertions(+), 60 deletions(-) diff --git a/BSIPA-ModList/UI/ViewControllers/MarkdownView.cs b/BSIPA-ModList/UI/ViewControllers/MarkdownView.cs index e991b07a..90cece20 100644 --- a/BSIPA-ModList/UI/ViewControllers/MarkdownView.cs +++ b/BSIPA-ModList/UI/ViewControllers/MarkdownView.cs @@ -72,20 +72,6 @@ namespace BSIPA_ModList.UI.ViewControllers protected void Awake() { - /*view = GetComponent(); - view.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHide; - view.vertical = true; - view.horizontal = false; - view.scrollSensitivity = 0f; - view.inertia = true; - view.movementType = ScrollRect.MovementType.Clamped; - - scrollbar = new GameObject("Scrollbar", typeof(RectTransform)).AddComponent(); - scrollbar.transform.SetParent(transform); - scrollbar.direction = Scrollbar.Direction.TopToBottom; - scrollbar.interactable = true; - view.verticalScrollbar = scrollbar;*/ - gameObject.SetActive(false); var vpgo = new GameObject("Viewport"); @@ -103,23 +89,23 @@ namespace BSIPA_ModList.UI.ViewControllers vpim.sprite = WhitePixel; vpim.material = CustomUI.Utilities.UIUtilities.NoGlowMaterial; - //view.viewport = viewport; - content = new GameObject("Content Wrapper").AddComponent(); content.SetParent(viewport); - var contentLayout = content.gameObject.AddComponent(); - var contentFitter = content.gameObject.AddComponent(); - contentFitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; - contentFitter.verticalFit = ContentSizeFitter.FitMode.Unconstrained; - contentLayout.preferredWidth = contentLayout.minWidth = rectTransform.sizeDelta.x; // to be adjusted content.gameObject.AddComponent(); content.localPosition = Vector2.zero; - content.anchorMin = new Vector2(.5f, .5f); - content.anchorMax = new Vector2(.5f, .5f); + content.anchorMin = new Vector2(0f, 1f); + content.anchorMax = new Vector2(1f, 1f); content.anchoredPosition = Vector2.zero; - //content.sizeDelta = Vector2.zero; - - //view.content = content; + var contentLayout = content.gameObject.AddComponent(); + var contentFitter = content.gameObject.AddComponent(); + contentFitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; + contentFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; + contentLayout.childControlHeight = true; + contentLayout.childControlWidth = false; + contentLayout.childForceExpandHeight = false; + contentLayout.childForceExpandWidth = true; + contentLayout.childAlignment = TextAnchor.UpperCenter; + contentLayout.spacing = 0f; var pageUp = Instantiate(Resources.FindObjectsOfTypeAll