public static void Prefix(ref Hud __instance) { if (BuildExpansionMod.isEnabled.Value) { DefaultControls.Resources uiRes = new DefaultControls.Resources(); uiRes.standard = __instance.m_pieceCategoryRoot.transform.parent.GetChild(0).gameObject.GetComponent <Image>().sprite; myScroll = DefaultControls.CreateScrollbar(uiRes).GetComponent <Scrollbar>(); myScroll.GetComponent <RectTransform>().anchorMin = new Vector2(1f, 0f); myScroll.GetComponent <RectTransform>().anchorMax = new Vector2(1f, 1f); myScroll.GetComponent <RectTransform>().pivot = new Vector2(1f, 1f); myScroll.GetComponent <RectTransform>().localPosition = new Vector2(0, 0); myScroll.GetComponent <RectTransform>().sizeDelta = new Vector2(20, 0); myScroll.direction = Scrollbar.Direction.BottomToTop; myScroll.gameObject.GetComponent <Image>().color = new Color32(0, 0, 0, 150); myScroll.gameObject.transform.SetParent(__instance.m_pieceListRoot.transform.parent, false); PreventClickDragScrollRect testScroll = __instance.m_pieceListRoot.transform.parent.gameObject.AddComponent <PreventClickDragScrollRect>(); testScroll.content = __instance.m_pieceListRoot; testScroll.viewport = __instance.m_pieceListRoot.transform.parent.gameObject.GetComponent <RectTransform>(); testScroll.verticalScrollbar = myScroll; testScroll.movementType = ScrollRect.MovementType.Clamped; testScroll.inertia = false; testScroll.scrollSensitivity = __instance.m_pieceIconSpacing; testScroll.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHide; visibilityInsurance = testScroll.gameObject.AddComponent <ScrollRectEnsureVisible>(); __instance.m_pieceListRoot.sizeDelta = new Vector2((int)(__instance.m_pieceIconSpacing * BuildExpansionMod.newGridWidth.Value), (int)(__instance.m_pieceIconSpacing * BuildExpansionMod.maxGridHeight.Value) + 16); } }
private void Awake() { mScrollRect = GetComponent <PreventClickDragScrollRect>(); mScrollTransform = mScrollRect.transform as RectTransform; mContent = mScrollRect.content; Reset(); }