/// <summary> /// Find the scroll view to work with. /// </summary> void FindScrollView() { // If the scroll view is on a parent, don't try to remember it (as we want it to be dynamic in case of re-parenting) UIScrollViewOptimized sv = NGUITools.FindInParents <UIScrollViewOptimized>(mTrans); if (scrollView == null || (mAutoFind && sv != scrollView)) { scrollView = sv; mAutoFind = true; } else if (scrollView == sv) { mAutoFind = true; } mScroll = scrollView; }
/// <summary> /// Automatically find the scroll view if possible. /// </summary> void OnEnable() { mTrans = transform; // Auto-upgrade if (scrollView == null && draggablePanel != null) { scrollView = draggablePanel; draggablePanel = null; } if (mStarted && (mAutoFind || mScroll == null)) { FindScrollView(); } }
/// <summary> /// Create a plane on which we will be performing the dragging. /// </summary> void OnPress(bool pressed) { // If the scroll view has been set manually, don't try to find it again if (mAutoFind && mScroll != scrollView) { mScroll = scrollView; mAutoFind = false; } if (scrollView && enabled && NGUITools.GetActive(gameObject)) { scrollView.Press(pressed); if (!pressed && mAutoFind) { scrollView = NGUITools.FindInParents <UIScrollViewOptimized>(mTrans); mScroll = scrollView; } } }