#pragma warning restore 0067 void Awake() { _RT = transform as RectTransform; _ResolvedAVGScreenSize = (Screen.width + Screen.height) / 2f; _ScrollRect = GetComponent <ScrollRect>(); _RefreshGizmo = GetComponentInChildren <PullToRefreshGizmo>(); // self or children if (_ScrollRect) { // May be null externalScrollRectProxy = _ScrollRect.GetComponent(typeof(IScrollRectProxy)) as IScrollRectProxy; } else { externalScrollRectProxy = GetComponentInParent(typeof(IScrollRectProxy)) as IScrollRectProxy; if (externalScrollRectProxy == null) { if (enabled) { Debug.Log(GetType().Name + ": no scrollRect provided and found no " + typeof(IScrollRectProxy).Name + " component among ancestors. Disabling..."); enabled = false; } return; } } }
void Awake() { _ResolvedAVGScreenSize = (Screen.width + Screen.height) / 2f; _ScrollRect = GetComponent <ScrollRect>(); _RefreshGizmo = GetComponentInChildren <PullToRefreshGizmo>(); // self or children // May be null externalScrollRectProxy = _ScrollRect.GetComponent(typeof(IScrollRectProxy)) as IScrollRectProxy; }
void Awake() { // Get in parent, but ignore self _ScrollRectProxy = transform.parent.GetComponentInParent <IScrollRectProxy>(); if (_ScrollRectProxy == null) { throw new UnityException(GetType().Name + ": No IScrollRectProxy component found in parent"); } _Scrollbar = GetComponent <Scrollbar>(); _ScrollbarPanelRT = _Scrollbar.transform as RectTransform; _OneIfVert_ZeroIfHor = _ScrollRectProxy.IsHorizontal ? 0 : 1; }
void Awake() { if (autoHideTime == 0f) { autoHideTime = 1f; } _Scrollbar = GetComponent <Scrollbar>(); _InitialScale = _Scrollbar.transform.localScale; _LastValue = _Scrollbar.value; _TimeOnLastValueChange = Time.time; _HorizontalScrollBar = _Scrollbar.direction == Scrollbar.Direction.LeftToRight || _Scrollbar.direction == Scrollbar.Direction.RightToLeft; if (!scrollRect) { scrollRect = GetComponentInParent <ScrollRect>(); //if (!scrollRect) // throw new UnityException("Please provide a ScrollRect for SmartScrollViewScrollbar to work"); } if (scrollRect) { _ScrollRectRT = scrollRect.transform as RectTransform; if (!viewport) { viewport = _ScrollRectRT; } if (_HorizontalScrollBar) { if (!scrollRect.horizontal) { throw new UnityException("Can't use horizontal scrollbar with non-horizontal scrollRect"); } if (scrollRect.horizontalScrollbar) { Debug.Log("SmartScrollViewScrollbar: setting scrollRect.horizontalScrollbar to null (the whole point of using SmartScrollViewScrollbar is to NOT have any scrollbars assigned)"); scrollRect.horizontalScrollbar = null; } if (scrollRect.verticalScrollbar == _Scrollbar) { Debug.Log("SmartScrollViewScrollbar: Can't use the same scrollbar for both vert and hor"); scrollRect.verticalScrollbar = null; } } else { if (!scrollRect.vertical) { throw new UnityException("Can't use vertical scrollbar with non-vertical scrollRect"); } if (scrollRect.verticalScrollbar) { Debug.Log("SmartScrollViewScrollbar: setting scrollRect.verticalScrollbar to null (the whole point of using SmartScrollViewScrollbar is to NOT have any scrollbars assigned)"); scrollRect.verticalScrollbar = null; } if (scrollRect.horizontalScrollbar == _Scrollbar) { Debug.Log("SmartScrollViewScrollbar: Can't use the same scrollbar for both vert and hor"); scrollRect.horizontalScrollbar = null; } } } else { Debug.LogError("No ScrollRect assigned!"); } if (autoHide) { UpdateStartingValuesForAutoHideEffect(); } scrollRect.onValueChanged.AddListener(ScrollRect_OnValueChangedCalled); // May be null externalScrollRectProxy = scrollRect.GetComponent(typeof(IScrollRectProxy)) as IScrollRectProxy; }
public static RectTransform.Edge GetEndEdge(this IScrollRectProxy proxy) { return(proxy.IsHorizontal ? RectTransform.Edge.Right : RectTransform.Edge.Bottom); }
public static RectTransform.Edge GetStartEdge(this IScrollRectProxy proxy) { return(proxy.IsHorizontal ? RectTransform.Edge.Left : RectTransform.Edge.Top); }
public static double GetContentSizeToViewportRatio(this IScrollRectProxy proxy) { return(proxy.GetContentSize() / proxy.GetViewportSize()); }
public static double GetScrollableArea(this IScrollRectProxy proxy) { return(proxy.GetContentSize() - proxy.GetViewportSize()); }