void OnEnable() { mTrans = transform; if (scrollView == null && draggablePanel != null) { scrollView = draggablePanel; draggablePanel = null; } FindScrollView(); }
/// <summary> /// scrollView 값을 넣을 때 꼭 이 함수로 호출할 것. /// </summary> public void SetScrollView(UIReuseScrollView scroll) { if (scroll == null) { Debug.LogWarning("scroll == null"); return; } scrollView = scroll; mScroll = scroll; mAutoFind = false; }
void FindScrollView() { UIReuseScrollView sv = NGUITools.FindInParents <UIReuseScrollView>(mTrans); if (scrollView == null) { scrollView = sv; mAutoFind = true; } else if (scrollView == sv) { mAutoFind = true; } mScroll = scrollView; }
void OnPress(bool pressed) { if (mAutoFind && mScroll != scrollView) { mScroll = scrollView; mAutoFind = false; } if (scrollView && enabled && NGUITools.GetActive(gameObject)) { scrollView.Press(pressed); if (!pressed && mAutoFind) { scrollView = NGUITools.FindInParents <UIReuseScrollView>(mTrans); mScroll = scrollView; } } }
static void AddReuseGrid() { UIReuseGrid grid = NGUITools.AddChild <UIReuseGrid>(NGUIEditorTools.SelectedRoot()); UIReuseScrollView scrollView = grid.transform.parent.GetComponent <UIReuseScrollView>(); if (scrollView != null) { grid.m_ReuseScrollView = scrollView; } UIPanel panel = grid.transform.parent.GetComponent <UIPanel>(); if (panel != null) { grid.transform.localPosition = new Vector3(panel.finalClipRegion.z * -0.5f + panel.finalClipRegion.x, panel.finalClipRegion.w * 0.5f + panel.finalClipRegion.y, 0.0f); } Selection.activeGameObject = grid.gameObject; }
/// <summary> /// 데이터 초기화 처리. /// </summary> /// <code> /// m_UIReuseGrid.InitData( () => /// { /// GameObject go = Instantiate(m_ScrollViewPrefab) as GameObject; /// CustomReuseCellData custom = go.GetComponent<CustomReuseCellData>(); /// // 추가적으로 해야할 것들 처리. /// return go; /// }); /// </code> /// <param name="function">이름</param> public void InitData(Func function) { if (IsInit()) { return; } create_fn = function; if (m_listData == null) { m_listData = new List <IReuseCellData>(); } if (m_ScrollView == null) { if (m_ReuseScrollView != null) { m_ScrollView = m_ReuseScrollView; } else { m_ScrollView = NGUITools.FindInParents <UIReuseScrollView>(gameObject); } } Repostion(); if (m_Column > 1) { m_cellList = new UIReuseScrollViewCell[m_maxLine * m_Column]; } else { m_cellList = new UIReuseScrollViewCell[m_maxLine]; } CreateListItem(); }