private void OnItemDataBinding(object sender, VirtualizingTreeViewItemDataBindingArgs e)
        {
            ProjectItem item = e.Item as ProjectItem;

            if (item != null)
            {
                Text text = e.ItemPresenter.GetComponentInChildren <Text>(true);
                text.text = item.Name;

                ProjectItemView itemView = e.ItemPresenter.GetComponentInChildren <ProjectItemView>(true);
                itemView.ProjectItem = item;

                Toggle toogle = e.ItemPresenter.GetComponentInChildren <Toggle>(true);
                toogle.isOn = m_treeView.IsItemSelected(item);

                AssetLibraryImportStatus status = e.ItemPresenter.GetComponentInChildren <AssetLibraryImportStatus>(true);
                if (item is ImportItem)
                {
                    ImportItem importItem = (ImportItem)item;
                    status.Current = importItem.Status;
                }
                else
                {
                    status.Current = ImportStatus.None;
                }

                e.HasChildren = item.Children != null && item.Children.Count > 0;
            }
        }
        private void OnValueChanged(bool value)
        {
            if (value == m_treeView.IsItemSelected(m_treeViewItem.Item))
            {
                return;
            }

            HashSet <object> selection;

            if (m_treeView.SelectedItems != null)
            {
                selection = new HashSet <object>(m_treeView.SelectedItems.OfType <object>().ToList());
            }
            else
            {
                selection = new HashSet <object>();
            }

            if (value)
            {
                OnSelected(m_treeViewItem.TreeViewItemData.Item, selection);
            }
            else
            {
                OnUnselected(m_treeViewItem.TreeViewItemData.Item, selection);
            }
            m_treeView.SelectedItems = selection;
        }
        private void Start()
        {
            m_treeViewItem = GetComponentInParent <VirtualizingTreeViewItem>();
            m_treeView     = GetComponentInParent <VirtualizingTreeView>();
            m_toggle       = GetComponent <Toggle>();
            m_toggle.isOn  = m_treeView.IsItemSelected(m_treeViewItem.Item);
            m_toggle.onValueChanged.AddListener(OnValueChanged);

            VirtualizingItemContainer.Selected   += OnSelected;
            VirtualizingItemContainer.Unselected += OnUnselected;
        }
Beispiel #4
0
        private void OnItemDataBinding(object sender, VirtualizingTreeViewItemDataBindingArgs e)
        {
            ProjectItem item = e.Item as ProjectItem;

            if (item != null)
            {
                Text text = e.ItemPresenter.GetComponentInChildren <Text>(true);
                text.text = item.Name;

                ProjectItemView itemView = e.ItemPresenter.GetComponentInChildren <ProjectItemView>(true);
                itemView.ProjectItem = item;

                Toggle toogle = e.ItemPresenter.GetComponentInChildren <Toggle>();
                toogle.isOn = m_treeView.IsItemSelected(item);

                e.HasChildren = item.Children != null && item.Children.Count > 0;
            }
        }