// Use this for initialization void Start() { int count = TreeViewDataSourceMgr.Get.TreeViewItemCount; for (int i = 0; i < count; ++i) { int childCount = TreeViewDataSourceMgr.Get.GetItemDataByIndex(i).ChildCount; mTreeItemCountMgr.AddTreeItem(childCount, true); } mLoopListView.InitListView(mTreeItemCountMgr.GetTotalItemAndChildCount(), OnGetItemByIndex); mExpandAllButton = GameObject.Find("ButtonPanel/buttonGroup1/ExpandAllButton").GetComponent <Button>(); mScrollToButton = GameObject.Find("ButtonPanel/buttonGroup2/ScrollToButton").GetComponent <Button>(); mCollapseAllButton = GameObject.Find("ButtonPanel/buttonGroup3/CollapseAllButton").GetComponent <Button>(); mScrollToInputItem = GameObject.Find("ButtonPanel/buttonGroup2/ScrollToInputFieldItem").GetComponent <InputField>(); mScrollToInputChild = GameObject.Find("ButtonPanel/buttonGroup2/ScrollToInputFieldChild").GetComponent <InputField>(); mScrollToButton.onClick.AddListener(OnJumpBtnClicked); mBackButton = GameObject.Find("ButtonPanel/BackButton").GetComponent <Button>(); mBackButton.onClick.AddListener(OnBackBtnClicked); mExpandAllButton.onClick.AddListener(OnExpandAllBtnClicked); mCollapseAllButton.onClick.AddListener(OnCollapseAllBtnClicked); mStickeyHeadItemHeight = mStickeyHeadItem.GetComponent <RectTransform>().rect.height; mStickeyHeadItem.Init(); mStickeyHeadItem.SetClickCallBack(this.OnExpandClicked); mLoopListView.ScrollRect.onValueChanged.AddListener(OnScrollContentPosChanged); UpdateStickeyHeadPos(); }
// Use this for initialization void Start() { int count = TreeViewDataSourceMgr.Get.TreeViewItemCount; //tells mTreeItemCountMgr there are how many TreeItems and every TreeItem has how many ChildItems. for (int i = 0; i < count; ++i) { int childCount = TreeViewDataSourceMgr.Get.GetItemDataByIndex(i).ChildCount; //second param "true" tells mTreeItemCountMgr this TreeItem is in expand status, that is to say all its children are showing. mTreeItemCountMgr.AddTreeItem(childCount, true); } //initialize the InitListView //mTreeItemCountMgr.GetTotalItemAndChildCount() return the total items count in the TreeView, include all TreeItems and all TreeChildItems. mLoopListView.InitListView(mTreeItemCountMgr.GetTotalItemAndChildCount(), OnGetItemByIndex); mExpandAllButton = GameObject.Find("ButtonPanel/buttonGroup1/ExpandAllButton").GetComponent <Button>(); mScrollToButton = GameObject.Find("ButtonPanel/buttonGroup2/ScrollToButton").GetComponent <Button>(); mCollapseAllButton = GameObject.Find("ButtonPanel/buttonGroup3/CollapseAllButton").GetComponent <Button>(); mScrollToInputItem = GameObject.Find("ButtonPanel/buttonGroup2/ScrollToInputFieldItem").GetComponent <InputField>(); mScrollToInputChild = GameObject.Find("ButtonPanel/buttonGroup2/ScrollToInputFieldChild").GetComponent <InputField>(); mScrollToButton.onClick.AddListener(OnJumpBtnClicked); mBackButton = GameObject.Find("ButtonPanel/BackButton").GetComponent <Button>(); mBackButton.onClick.AddListener(OnBackBtnClicked); mExpandAllButton.onClick.AddListener(OnExpandAllBtnClicked); mCollapseAllButton.onClick.AddListener(OnCollapseAllBtnClicked); mAddNewButton = GameObject.Find("ButtonPanel/buttonGroup4/AddNewButton").GetComponent <Button>(); mAddNewInputItem = GameObject.Find("ButtonPanel/buttonGroup4/AddNewInputFieldItem").GetComponent <InputField>(); mAddNewInputChild = GameObject.Find("ButtonPanel/buttonGroup4/AddNewInputFieldChild").GetComponent <InputField>(); mAddNewButton.onClick.AddListener(OnAddNewBtnClicked); mStickeyHeadItemHeight = mStickeyHeadItem.GetComponent <RectTransform>().rect.height; mStickeyHeadItem.Init(); mStickeyHeadItem.SetClickCallBack(this.OnExpandClicked); mStickeyHeadItemRf = mStickeyHeadItem.gameObject.GetComponent <RectTransform>(); mLoopListView.ScrollRect.onValueChanged.AddListener(OnScrollContentPosChanged); UpdateStickeyHeadPos(); }