private void SelectionChanged(int[] selectedIDs) { this.m_Selection = new List <PackageImportTreeView.PackageImportTreeViewItem>(); IList <TreeViewItem> rows = this.m_TreeView.data.GetRows(); foreach (TreeViewItem current in rows) { if (selectedIDs.Contains(current.id)) { PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = current as PackageImportTreeView.PackageImportTreeViewItem; if (packageImportTreeViewItem != null) { this.m_Selection.Add(packageImportTreeViewItem); } } } ImportPackageItem item = this.m_Selection[0].item; if (this.m_Selection.Count == 1 && item != null && !string.IsNullOrEmpty(item.previewPath)) { PackageImportTreeView.PackageImportTreeViewGUI packageImportTreeViewGUI = this.m_TreeView.gui as PackageImportTreeView.PackageImportTreeViewGUI; packageImportTreeViewGUI.showPreviewForID = this.m_Selection[0].id; } else { PopupWindowWithoutFocus.Hide(); } }
private void DoPreviewPopup(PackageImportTreeView.PackageImportTreeViewItem pitem, Rect rowRect) { ImportPackageItem item = pitem.item; if (item != null) { if (Event.current.type == EventType.MouseDown && rowRect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible()) { this.showPreviewForID = pitem.id; } if (pitem.id == this.showPreviewForID && Event.current.type != EventType.Layout) { this.showPreviewForID = 0; if (!string.IsNullOrEmpty(item.previewPath)) { Texture2D preview = PackageImport.GetPreview(item.previewPath); Rect rect = rowRect; rect.width = EditorGUIUtility.currentViewWidth; Rect arg_AF_0 = rect; PopupWindowContent arg_AF_1 = new PackageImportTreeView.PreviewPopup(preview); PopupLocationHelper.PopupLocation[] expr_A7 = new PopupLocationHelper.PopupLocation[3]; expr_A7[0] = PopupLocationHelper.PopupLocation.Right; expr_A7[1] = PopupLocationHelper.PopupLocation.Left; PopupWindowWithoutFocus.Show(arg_AF_0, arg_AF_1, expr_A7); } } } }
private PackageImportTreeView.Amount GetFolderChildrenEnabledState(PackageImportTreeView.PackageImportTreeViewItem folder) { if (!folder.isFolder) { Debug.LogError("Should be a folder item!"); } if (!folder.hasChildren) { return(PackageImportTreeView.Amount.None); } PackageImportTreeView.Amount amount = PackageImportTreeView.Amount.NotSet; PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = folder.children[0] as PackageImportTreeView.PackageImportTreeViewItem; int enabled = packageImportTreeViewItem.item.enabled; for (int i = 1; i < folder.children.Count; i++) { if (enabled != (folder.children[i] as PackageImportTreeView.PackageImportTreeViewItem).item.enabled) { amount = PackageImportTreeView.Amount.Mixed; break; } } if (amount == PackageImportTreeView.Amount.NotSet) { amount = ((enabled != 1) ? PackageImportTreeView.Amount.None : PackageImportTreeView.Amount.All); } return(amount); }
private void SelectionChanged(int[] selectedIDs) { this.m_Selection = new List <PackageImportTreeView.PackageImportTreeViewItem>(); using (List <TreeViewItem> .Enumerator enumerator = this.m_TreeView.data.GetRows().GetEnumerator()) { while (enumerator.MoveNext()) { TreeViewItem current = enumerator.Current; if (((IEnumerable <int>)selectedIDs).Contains <int>(current.id)) { PackageImportTreeView.PackageImportTreeViewItem importTreeViewItem = current as PackageImportTreeView.PackageImportTreeViewItem; if (importTreeViewItem != null) { this.m_Selection.Add(importTreeViewItem); } } } } ImportPackageItem importPackageItem = this.m_Selection[0].item; if (this.m_Selection.Count == 1 && importPackageItem != null && !string.IsNullOrEmpty(importPackageItem.previewPath)) { (this.m_TreeView.gui as PackageImportTreeView.PackageImportTreeViewGUI).showPreviewForID = this.m_Selection[0].id; } else { PopupWindowWithoutFocus.Hide(); } }
private void DoPreviewPopup(PackageImportTreeView.PackageImportTreeViewItem pitem, Rect rowRect) { ImportPackageItem item = pitem.item; if (item != null) { if (((Event.current.type == EventType.MouseDown) && rowRect.Contains(Event.current.mousePosition)) && !PopupWindowWithoutFocus.IsVisible()) { this.showPreviewForID = pitem.id; } if ((pitem.id == this.showPreviewForID) && (Event.current.type != EventType.Layout)) { this.showPreviewForID = 0; if (!string.IsNullOrEmpty(item.previewPath)) { Texture2D preview = PackageImport.GetPreview(item.previewPath); Rect activatorRect = rowRect; activatorRect.width = EditorGUIUtility.currentViewWidth; PopupLocationHelper.PopupLocation[] locationPriorityOrder = new PopupLocationHelper.PopupLocation[3]; locationPriorityOrder[0] = PopupLocationHelper.PopupLocation.Right; locationPriorityOrder[1] = PopupLocationHelper.PopupLocation.Left; PopupWindowWithoutFocus.Show(activatorRect, new PackageImportTreeView.PreviewPopup(preview), locationPriorityOrder); } } } }
private void RecursiveComputeEnabledStateForFolders(PackageImportTreeView.PackageImportTreeViewItem pitem, HashSet <PackageImportTreeView.PackageImportTreeViewItem> done) { ImportPackageItem item = pitem.item; if (item != null && !item.isFolder) { return; } if (pitem.hasChildren) { foreach (TreeViewItem current in pitem.children) { this.RecursiveComputeEnabledStateForFolders(current as PackageImportTreeView.PackageImportTreeViewItem, done); } } if (item != null && !done.Contains(pitem)) { PackageImportTreeView.EnabledState folderChildrenEnabledState = this.GetFolderChildrenEnabledState(pitem); item.enabledStatus = (int)folderChildrenEnabledState; if (folderChildrenEnabledState == PackageImportTreeView.EnabledState.Mixed) { done.Add(pitem); for (PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = pitem.parent as PackageImportTreeView.PackageImportTreeViewItem; packageImportTreeViewItem != null; packageImportTreeViewItem = (packageImportTreeViewItem.parent as PackageImportTreeView.PackageImportTreeViewItem)) { ImportPackageItem item2 = packageImportTreeViewItem.item; if (item2 != null && !done.Contains(packageImportTreeViewItem)) { item2.enabledStatus = 2; done.Add(packageImportTreeViewItem); } } } } }
private PackageImportTreeView.EnabledState GetFolderChildrenEnabledState(PackageImportTreeView.PackageImportTreeViewItem folder) { ImportPackageItem item = folder.item; if (item != null && !item.isFolder) { Debug.LogError("Should be a folder item!"); } if (!folder.hasChildren) { return(PackageImportTreeView.EnabledState.None); } PackageImportTreeView.EnabledState enabledState = PackageImportTreeView.EnabledState.NotSet; PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = folder.children[0] as PackageImportTreeView.PackageImportTreeViewItem; ImportPackageItem item2 = packageImportTreeViewItem.item; int num = (item2 != null) ? item2.enabledStatus : 1; for (int i = 1; i < folder.children.Count; i++) { item2 = (folder.children[i] as PackageImportTreeView.PackageImportTreeViewItem).item; if (num != item2.enabledStatus) { enabledState = PackageImportTreeView.EnabledState.Mixed; break; } } if (enabledState == PackageImportTreeView.EnabledState.NotSet) { enabledState = ((num != 1) ? PackageImportTreeView.EnabledState.None : PackageImportTreeView.EnabledState.All); } return(enabledState); }
public override Rect OnRowGUI(TreeViewItem item, int row, float rowWidth, bool selected, bool focused) { Rect position = new Rect(0f, row * base.k_LineHeight, rowWidth, base.k_LineHeight); base.k_IndentWidth = 18f; base.k_FoldoutWidth = 18f; PackageImportTreeView.PackageImportTreeViewItem pitem = item as PackageImportTreeView.PackageImportTreeViewItem; bool flag = Event.current.type == EventType.Repaint; if (selected && flag) { TreeViewGUI.s_Styles.lineStyle.Draw(position, false, false, true, focused); } if (base.m_TreeView.data.IsExpandable(item)) { this.DoFoldout(item, position); } Rect toggleRect = new Rect((base.k_BaseIndent + (item.depth * base.indentWidth)) + base.k_FoldoutWidth, position.y, 18f, position.height); this.DoToggle(pitem, toggleRect); Rect contentRect = new Rect(toggleRect.xMax, position.y, position.width, position.height); this.DoIconAndText(item, contentRect, selected, focused); this.DoPreviewPopup(pitem, position); if ((pitem.item.exists == 0) && flag) { Texture image = Constants.badgeNew.image; GUI.DrawTexture(new Rect((position.xMax - image.width) - 6f, position.y + ((position.height - image.height) / 2f), (float)image.width, (float)image.height), image); } return(position); }
private void DoPreviewPopup(PackageImportTreeView.PackageImportTreeViewItem pitem, Rect rowRect) { ImportPackageItem importPackageItem = pitem.item; if (importPackageItem == null) { return; } if (Event.current.type == EventType.MouseDown && rowRect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible()) { this.showPreviewForID = pitem.id; } if (pitem.id != this.showPreviewForID || Event.current.type == EventType.Layout) { return; } this.showPreviewForID = 0; if (string.IsNullOrEmpty(importPackageItem.previewPath)) { return; } Texture2D preview = PackageImport.GetPreview(importPackageItem.previewPath); Rect activatorRect = rowRect; activatorRect.width = EditorGUIUtility.currentViewWidth; PopupWindowWithoutFocus.Show(activatorRect, (PopupWindowContent) new PackageImportTreeView.PreviewPopup(preview), new PopupLocationHelper.PopupLocation[3] { PopupLocationHelper.PopupLocation.Right, PopupLocationHelper.PopupLocation.Left, PopupLocationHelper.PopupLocation.Below }); }
private void RecursiveComputeEnabledStateForFolders(PackageImportTreeView.PackageImportTreeViewItem pitem, HashSet <PackageImportTreeView.PackageImportTreeViewItem> done) { if (pitem.item == null || pitem.item.isFolder) { if (pitem.hasChildren) { foreach (TreeViewItem current in pitem.children) { this.RecursiveComputeEnabledStateForFolders(current as PackageImportTreeView.PackageImportTreeViewItem, done); } } if (!done.Contains(pitem)) { PackageImportTreeView.EnabledState folderChildrenEnabledState = this.GetFolderChildrenEnabledState(pitem); pitem.enableState = folderChildrenEnabledState; if (folderChildrenEnabledState == PackageImportTreeView.EnabledState.Mixed) { done.Add(pitem); for (PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = pitem.parent as PackageImportTreeView.PackageImportTreeViewItem; packageImportTreeViewItem != null; packageImportTreeViewItem = (packageImportTreeViewItem.parent as PackageImportTreeView.PackageImportTreeViewItem)) { if (!done.Contains(packageImportTreeViewItem)) { packageImportTreeViewItem.enableState = PackageImportTreeView.EnabledState.Mixed; done.Add(packageImportTreeViewItem); } } } } } }
private TreeViewItem EnsureFolderPath(string folderPath, Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem> treeViewFolders, bool initExpandedState) { TreeViewItem result; if (folderPath == "") { result = this.m_RootItem; } else { int hashCode = folderPath.GetHashCode(); TreeViewItem treeViewItem = TreeViewUtility.FindItem(hashCode, this.m_RootItem); if (treeViewItem != null) { result = treeViewItem; } else { string[] array = folderPath.Split(new char[] { '/' }); string text = ""; TreeViewItem treeViewItem2 = this.m_RootItem; int num = -1; for (int i = 0; i < array.Length; i++) { string text2 = array[i]; if (text != "") { text += '/'; } text += text2; if (i != 0 || !(text == "Assets")) { num++; hashCode = text.GetHashCode(); PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem; if (treeViewFolders.TryGetValue(text, out packageImportTreeViewItem)) { treeViewItem2 = packageImportTreeViewItem; } else { PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem2 = new PackageImportTreeView.PackageImportTreeViewItem(null, hashCode, num, treeViewItem2, text2); treeViewItem2.AddChild(packageImportTreeViewItem2); treeViewItem2 = packageImportTreeViewItem2; if (initExpandedState) { this.m_TreeView.state.expandedIDs.Add(hashCode); } treeViewFolders[text] = packageImportTreeViewItem2; } } } result = treeViewItem2; } } return(result); }
public override void OnRowGUI(Rect rowRect, TreeViewItem tvItem, int row, bool selected, bool focused) { this.k_IndentWidth = 18f; this.k_FoldoutWidth = 18f; PackageImportTreeView.PackageImportTreeViewItem pitem = tvItem as PackageImportTreeView.PackageImportTreeViewItem; ImportPackageItem importPackageItem = pitem.item; bool flag1 = Event.current.type == EventType.Repaint; if (selected && flag1) { TreeViewGUI.s_Styles.selectionStyle.Draw(rowRect, false, false, true, focused); } bool flag2 = importPackageItem != null; bool flag3 = importPackageItem == null || importPackageItem.isFolder; bool flag4 = importPackageItem != null && importPackageItem.assetChanged; bool flag5 = importPackageItem != null && importPackageItem.pathConflict; bool flag6 = importPackageItem == null || importPackageItem.exists; bool flag7 = importPackageItem != null && importPackageItem.projectAsset; bool doReInstall = this.m_PackageImportView.doReInstall; if (this.m_TreeView.data.IsExpandable(tvItem)) { this.DoFoldout(rowRect, tvItem, row); } Rect toggleRect = new Rect(this.k_BaseIndent + (float)tvItem.depth * this.indentWidth + this.k_FoldoutWidth, rowRect.y, 18f, rowRect.height); if (flag3 && !flag7 || flag2 && !flag7 && (flag4 || doReInstall)) { this.DoToggle(pitem, toggleRect); } EditorGUI.BeginDisabledGroup(!flag2 || flag7); Rect contentRect = new Rect(toggleRect.xMax, rowRect.y, rowRect.width, rowRect.height); this.DoIconAndText(tvItem, contentRect, selected, focused); this.DoPreviewPopup(pitem, rowRect); if (flag1 && flag2 && flag5) { Rect position = new Rect(rowRect.xMax - 58f, rowRect.y, rowRect.height, rowRect.height); EditorGUIUtility.SetIconSize(new Vector2(rowRect.height, rowRect.height)); GUI.Label(position, PackageImportTreeView.PackageImportTreeViewGUI.Constants.badgeWarn); EditorGUIUtility.SetIconSize(Vector2.zero); } if (flag1 && flag2 && (!flag6 && !flag5)) { Texture image = PackageImportTreeView.PackageImportTreeViewGUI.Constants.badgeNew.image; GUI.Label(new Rect((float)((double)rowRect.xMax - (double)image.width - 6.0), rowRect.y + (float)(((double)rowRect.height - (double)image.height) / 2.0), (float)image.width, (float)image.height), PackageImportTreeView.PackageImportTreeViewGUI.Constants.badgeNew, PackageImportTreeView.PackageImportTreeViewGUI.Constants.paddinglessStyle); } if (flag1 && doReInstall && flag7) { Texture image = PackageImportTreeView.PackageImportTreeViewGUI.Constants.badgeDelete.image; GUI.Label(new Rect((float)((double)rowRect.xMax - (double)image.width - 6.0), rowRect.y + (float)(((double)rowRect.height - (double)image.height) / 2.0), (float)image.width, (float)image.height), PackageImportTreeView.PackageImportTreeViewGUI.Constants.badgeDelete, PackageImportTreeView.PackageImportTreeViewGUI.Constants.paddinglessStyle); } if (flag1 && flag2 && (flag6 || flag5) && flag4) { Texture image = PackageImportTreeView.PackageImportTreeViewGUI.Constants.badgeChange.image; GUI.Label(new Rect((float)((double)rowRect.xMax - (double)image.width - 6.0), rowRect.y, rowRect.height, rowRect.height), PackageImportTreeView.PackageImportTreeViewGUI.Constants.badgeChange, PackageImportTreeView.PackageImportTreeViewGUI.Constants.paddinglessStyle); } EditorGUI.EndDisabledGroup(); }
private void ComputeEnabledStateForFolders() { PackageImportTreeView.PackageImportTreeViewItem root = this.m_TreeView.data.root as PackageImportTreeView.PackageImportTreeViewItem; this.RecursiveComputeEnabledStateForFolders(root, new HashSet <PackageImportTreeView.PackageImportTreeViewItem>() { root }); }
protected override Texture GetIconForNode(TreeViewItem item) { PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = item as PackageImportTreeView.PackageImportTreeViewItem; if (packageImportTreeViewItem.isFolder) { return(this.constants.folderIcon); } return(InternalEditorUtility.GetIconForFile(packageImportTreeViewItem.item.pathName)); }
public override Rect OnRowGUI(TreeViewItem node, int row, float rowWidth, bool selected, bool focused) { Rect rect = new Rect(0f, (float)row * this.k_LineHeight, rowWidth, this.k_LineHeight); this.DoNodeGUI(rect, node, selected, focused, false); PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = node as PackageImportTreeView.PackageImportTreeViewItem; if (packageImportTreeViewItem != null) { Rect toggleRect = new Rect(2f, rect.y, rect.height, rect.height); EditorGUI.BeginChangeCheck(); PackageImportTreeView.PackageImportTreeViewGUI.Toggle(packageImportTreeViewItem, toggleRect); if (EditorGUI.EndChangeCheck()) { if (this.m_TreeView.GetSelection().Length <= 1 || !this.m_TreeView.GetSelection().Contains(packageImportTreeViewItem.id)) { this.m_TreeView.SetSelection(new int[] { packageImportTreeViewItem.id }, false); this.m_TreeView.NotifyListenersThatSelectionChanged(); } if (this.itemWasToggled != null) { this.itemWasToggled(packageImportTreeViewItem); } Event.current.Use(); } if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible()) { this.showPreviewForID = packageImportTreeViewItem.id; } if (packageImportTreeViewItem.id == this.showPreviewForID && Event.current.type != EventType.Layout) { this.showPreviewForID = 0; if (!string.IsNullOrEmpty(packageImportTreeViewItem.item.previewPath)) { Texture2D preview = PackageImport.GetPreview(packageImportTreeViewItem.item.previewPath); Rect rect2 = rect; rect2.width = EditorGUIUtility.currentViewWidth; Rect arg_190_0 = rect2; PopupWindowContent arg_190_1 = new PackageImportTreeView.PreviewPopup(preview); PopupLocationHelper.PopupLocation[] expr_188 = new PopupLocationHelper.PopupLocation[3]; expr_188[0] = PopupLocationHelper.PopupLocation.Right; expr_188[1] = PopupLocationHelper.PopupLocation.Left; PopupWindowWithoutFocus.Show(arg_190_0, arg_190_1, expr_188); } } if (packageImportTreeViewItem.item.exists == 0) { Texture image = this.constants.badgeNew.image; GUI.DrawTexture(new Rect(rect.xMax - (float)image.width - 6f, rect.y + (rect.height - (float)image.height) / 2f, (float)image.width, (float)image.height), image); } } return(rect); }
private void EnableChildrenRecursive(TreeViewItem parentItem, PackageImportTreeView.EnabledState state) { if (parentItem.hasChildren) { foreach (TreeViewItem current in parentItem.children) { PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = current as PackageImportTreeView.PackageImportTreeViewItem; packageImportTreeViewItem.enableState = state; this.EnableChildrenRecursive(packageImportTreeViewItem, state); } } }
private void EnableChildrenRecursive(TreeViewItem parentItem, int enabled) { if (!parentItem.hasChildren) { return; } foreach (TreeViewItem current in parentItem.children) { PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = current as PackageImportTreeView.PackageImportTreeViewItem; packageImportTreeViewItem.item.enabled = enabled; this.EnableChildrenRecursive(packageImportTreeViewItem, enabled); } }
private TreeViewItem EnsureFolderPath(string folderPath, Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem> treeViewFolders, bool initExpandedState) { if (folderPath == string.Empty) { return(base.m_RootItem); } TreeViewItem item = TreeViewUtility.FindItem(folderPath.GetHashCode(), base.m_RootItem); if (item != null) { return(item); } char[] separator = new char[] { '/' }; string[] strArray = folderPath.Split(separator); string key = string.Empty; TreeViewItem rootItem = base.m_RootItem; int depth = -1; for (int i = 0; i < strArray.Length; i++) { string displayName = strArray[i]; if (key != string.Empty) { key = key + '/'; } key = key + displayName; if ((i != 0) || (key != "Assets")) { PackageImportTreeView.PackageImportTreeViewItem item3; depth++; int hashCode = key.GetHashCode(); if (treeViewFolders.TryGetValue(key, out item3)) { rootItem = item3; } else { PackageImportTreeView.PackageImportTreeViewItem child = new PackageImportTreeView.PackageImportTreeViewItem(null, hashCode, depth, rootItem, displayName); rootItem.AddChild(child); rootItem = child; if (initExpandedState) { base.m_TreeView.state.expandedIDs.Add(hashCode); } treeViewFolders[key] = child; } } } return(rootItem); }
private bool ItemShouldBeConsideredForEnabledCheck(PackageImportTreeView.PackageImportTreeViewItem pitem) { if (pitem == null) { return(false); } if (pitem.item == null) { return(true); } ImportPackageItem importPackageItem = pitem.item; return(!importPackageItem.projectAsset && (importPackageItem.isFolder || importPackageItem.assetChanged || this.doReInstall)); }
private TreeViewItem EnsureFolderPath(string folderPath, Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem> treeViewFolders, bool initExpandedState) { if (folderPath == string.Empty) { return(this.m_RootItem); } TreeViewItem treeViewItem = TreeViewUtility.FindItem(folderPath.GetHashCode(), this.m_RootItem); if (treeViewItem != null) { return(treeViewItem); } string[] strArray = folderPath.Split('/'); string empty = string.Empty; TreeViewItem parent = this.m_RootItem; int depth = -1; for (int index = 0; index < strArray.Length; ++index) { string displayName = strArray[index]; if (empty != string.Empty) { empty += (string)(object)'/'; } empty += displayName; if (index != 0 || !(empty == "Assets")) { ++depth; int hashCode = empty.GetHashCode(); PackageImportTreeView.PackageImportTreeViewItem importTreeViewItem1; if (treeViewFolders.TryGetValue(empty, out importTreeViewItem1)) { parent = (TreeViewItem)importTreeViewItem1; } else { PackageImportTreeView.PackageImportTreeViewItem importTreeViewItem2 = new PackageImportTreeView.PackageImportTreeViewItem((ImportPackageItem)null, hashCode, depth, parent, displayName); parent.AddChild((TreeViewItem)importTreeViewItem2); parent = (TreeViewItem)importTreeViewItem2; if (initExpandedState) { this.m_TreeView.state.expandedIDs.Add(hashCode); } treeViewFolders[empty] = importTreeViewItem2; } } } return(parent); }
protected override Texture GetIconForNode(TreeViewItem item) { PackageImportTreeView.PackageImportTreeViewItem item2 = item as PackageImportTreeView.PackageImportTreeViewItem; if (item2.isFolder) { return(Constants.folderIcon); } Texture cachedIcon = AssetDatabase.GetCachedIcon(item2.item.pathName); if (cachedIcon != null) { return(cachedIcon); } return(InternalEditorUtility.GetIconForFile(item2.item.pathName)); }
private void ItemWasToggled(PackageImportTreeView.PackageImportTreeViewItem pitem) { if (this.m_Selection.Count <= 1) { this.EnableChildrenRecursive(pitem, pitem.enableState); } else { foreach (PackageImportTreeView.PackageImportTreeViewItem current in this.m_Selection) { current.enableState = pitem.enableState; } } this.ComputeEnabledStateForFolders(); }
private static void Toggle(PackageImportTreeView.PackageImportTreeViewItem pitem, Rect toggleRect) { bool flag = pitem.item.enabled > 0; GUIStyle toggle = EditorStyles.toggle; if (pitem.isFolder && (pitem.item.enabled == 2)) { toggle = EditorStyles.toggleMixed; } bool flag3 = GUI.Toggle(toggleRect, flag, GUIContent.none, toggle); if (flag3 != flag) { pitem.item.enabled = !flag3 ? 0 : 1; } }
private void EnableChildrenRecursive(TreeViewItem parentItem, PackageImportTreeView.EnabledState state) { if (!parentItem.hasChildren) { return; } using (List <TreeViewItem> .Enumerator enumerator = parentItem.children.GetEnumerator()) { while (enumerator.MoveNext()) { PackageImportTreeView.PackageImportTreeViewItem current = enumerator.Current as PackageImportTreeView.PackageImportTreeViewItem; current.enableState = state; this.EnableChildrenRecursive((TreeViewItem)current, state); } } }
private void GetEnabledFoldersRecursive(TreeViewItem parentItem, List <string> folderPaths) { if (!parentItem.hasChildren) { return; } foreach (TreeViewItem current in parentItem.children) { PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = current as PackageImportTreeView.PackageImportTreeViewItem; if (packageImportTreeViewItem.isFolder && packageImportTreeViewItem.item.enabled > 0) { folderPaths.Add(packageImportTreeViewItem.item.pathName); } this.GetEnabledFoldersRecursive(packageImportTreeViewItem, folderPaths); } }
private PackageImportTreeView.EnabledState GetFolderChildrenEnabledState(PackageImportTreeView.PackageImportTreeViewItem folder) { if (folder.item != null && !folder.item.isFolder) { Debug.LogError("Should be a folder item!"); } PackageImportTreeView.EnabledState result; if (!folder.hasChildren) { result = PackageImportTreeView.EnabledState.None; } else { PackageImportTreeView.EnabledState enabledState = PackageImportTreeView.EnabledState.NotSet; int i; for (i = 0; i < folder.children.Count; i++) { PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = folder.children[i] as PackageImportTreeView.PackageImportTreeViewItem; if (this.ItemShouldBeConsideredForEnabledCheck(packageImportTreeViewItem)) { enabledState = packageImportTreeViewItem.enableState; break; } } for (i++; i < folder.children.Count; i++) { PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem2 = folder.children[i] as PackageImportTreeView.PackageImportTreeViewItem; if (this.ItemShouldBeConsideredForEnabledCheck(packageImportTreeViewItem2)) { if (enabledState != packageImportTreeViewItem2.enableState) { enabledState = PackageImportTreeView.EnabledState.Mixed; break; } } } if (enabledState == PackageImportTreeView.EnabledState.NotSet) { result = PackageImportTreeView.EnabledState.None; } else { result = enabledState; } } return(result); }
private void EnableChildrenRecursive(TreeViewItem parentItem, int enabled) { if (!parentItem.hasChildren) { return; } foreach (TreeViewItem current in parentItem.children) { PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = current as PackageImportTreeView.PackageImportTreeViewItem; ImportPackageItem item = packageImportTreeViewItem.item; if (item != null) { item.enabledStatus = enabled; } this.EnableChildrenRecursive(packageImportTreeViewItem, enabled); } }
private static void Toggle(ImportPackageItem[] items, PackageImportTreeView.PackageImportTreeViewItem pitem, Rect toggleRect) { bool flag = pitem.enableState > PackageImportTreeView.EnabledState.None; bool flag2 = (pitem.item == null) || pitem.item.isFolder; GUIStyle toggle = EditorStyles.toggle; if (flag2 && (pitem.enableState == PackageImportTreeView.EnabledState.Mixed)) { toggle = EditorStyles.toggleMixed; } bool flag4 = GUI.Toggle(toggleRect, flag, GUIContent.none, toggle); if (flag4 != flag) { pitem.enableState = !flag4 ? PackageImportTreeView.EnabledState.None : PackageImportTreeView.EnabledState.All; } }
private static void Toggle(PackageImportTreeView.PackageImportTreeViewItem pitem, Rect toggleRect) { bool flag = pitem.item.enabled > 0; GUIStyle style = EditorStyles.toggle; bool flag2 = pitem.isFolder && pitem.item.enabled == 2; if (flag2) { style = EditorStyles.toggleMixed; } bool flag3 = GUI.Toggle(toggleRect, flag, GUIContent.none, style); if (flag3 != flag) { pitem.item.enabled = ((!flag3) ? 0 : 1); } }
protected override Texture GetIconForNode(TreeViewItem tvItem) { PackageImportTreeView.PackageImportTreeViewItem item = tvItem as PackageImportTreeView.PackageImportTreeViewItem; ImportPackageItem item2 = item.item; if ((item2 == null) || item2.isFolder) { return(Constants.folderIcon); } Texture cachedIcon = AssetDatabase.GetCachedIcon(item2.destinationAssetPath); if (cachedIcon != null) { return(cachedIcon); } return(InternalEditorUtility.GetIconForFile(item2.destinationAssetPath)); }
private TreeViewItem EnsureFolderPath(string folderPath, Dictionary<string, AssetsItem> packageFolders, Dictionary<string, PackageImportTreeView.PackageImportTreeViewItem> treeViewFolders, bool initExpandedState) { int hashCode = folderPath.GetHashCode(); TreeViewItem treeViewItem = TreeViewUtility.FindItem(hashCode, this.m_RootItem); if (treeViewItem != null) { return treeViewItem; } string[] array = folderPath.Split(new char[] { '/' }); string text = string.Empty; TreeViewItem treeViewItem2 = this.m_RootItem; for (int i = 0; i < array.Length; i++) { string text2 = array[i]; if (text != string.Empty) { text += '/'; } text += text2; if (!(text == "Assets")) { hashCode = text.GetHashCode(); PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem; if (treeViewFolders.TryGetValue(text, out packageImportTreeViewItem)) { treeViewItem2 = packageImportTreeViewItem; } else { PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem2 = new PackageImportTreeView.PackageImportTreeViewItem(hashCode, i, treeViewItem2, text2); packageImportTreeViewItem2.isFolder = true; AssetsItem item; if (packageFolders.TryGetValue(text, out item)) { packageImportTreeViewItem2.item = item; } if (packageImportTreeViewItem2.item == null) { packageImportTreeViewItem2.item = new AssetsItem { assetIsDir = 1, pathName = text, exportedAssetPath = text, enabled = (this.m_EnabledFolders != null) ? ((!this.m_EnabledFolders.Contains(text)) ? 0 : 1) : 1, guid = AssetDatabase.AssetPathToGUID(text), previewPath = string.Empty }; packageImportTreeViewItem2.item.exists = ((!string.IsNullOrEmpty(packageImportTreeViewItem2.item.guid)) ? 1 : 0); } treeViewItem2.AddChild(packageImportTreeViewItem2); treeViewItem2 = packageImportTreeViewItem2; if (initExpandedState) { this.m_TreeView.state.expandedIDs.Add(hashCode); } treeViewFolders[text] = packageImportTreeViewItem2; } } } return treeViewItem2; }
public override void FetchData() { this.m_RootItem = (TreeViewItem) new PackageImportTreeView.PackageImportTreeViewItem((ImportPackageItem) null, "Assets".GetHashCode(), -1, (TreeViewItem) null, "InvisibleAssetsFolder"); bool initExpandedState = true; if (initExpandedState) this.m_TreeView.state.expandedIDs.Add(this.m_RootItem.id); ImportPackageItem[] packageItems = this.m_PackageImportView.packageItems; Dictionary<string, PackageImportTreeView.PackageImportTreeViewItem> treeViewFolders = new Dictionary<string, PackageImportTreeView.PackageImportTreeViewItem>(); for (int index = 0; index < packageItems.Length; ++index) { ImportPackageItem itemIn = packageItems[index]; if (!PackageImport.HasInvalidCharInFilePath(itemIn.destinationAssetPath)) { string fileName = Path.GetFileName(itemIn.destinationAssetPath); TreeViewItem parent = this.EnsureFolderPath(Path.GetDirectoryName(itemIn.destinationAssetPath), treeViewFolders, initExpandedState); if (parent != null) { int hashCode = itemIn.destinationAssetPath.GetHashCode(); PackageImportTreeView.PackageImportTreeViewItem importTreeViewItem = new PackageImportTreeView.PackageImportTreeViewItem(itemIn, hashCode, parent.depth + 1, parent, fileName); parent.AddChild((TreeViewItem) importTreeViewItem); if (initExpandedState) this.m_TreeView.state.expandedIDs.Add(hashCode); if (itemIn.isFolder) treeViewFolders[itemIn.destinationAssetPath] = importTreeViewItem; } } } if (!initExpandedState) return; this.m_TreeView.state.expandedIDs.Sort(); }
private TreeViewItem EnsureFolderPath(string folderPath, Dictionary<string, PackageImportTreeView.PackageImportTreeViewItem> treeViewFolders, bool initExpandedState) { if (folderPath == string.Empty) return this.m_RootItem; TreeViewItem treeViewItem = TreeViewUtility.FindItem(folderPath.GetHashCode(), this.m_RootItem); if (treeViewItem != null) return treeViewItem; string[] strArray = folderPath.Split('/'); string empty = string.Empty; TreeViewItem parent = this.m_RootItem; int depth = -1; for (int index = 0; index < strArray.Length; ++index) { string displayName = strArray[index]; if (empty != string.Empty) empty += (string) (object) '/'; empty += displayName; if (index != 0 || !(empty == "Assets")) { ++depth; int hashCode = empty.GetHashCode(); PackageImportTreeView.PackageImportTreeViewItem importTreeViewItem1; if (treeViewFolders.TryGetValue(empty, out importTreeViewItem1)) { parent = (TreeViewItem) importTreeViewItem1; } else { PackageImportTreeView.PackageImportTreeViewItem importTreeViewItem2 = new PackageImportTreeView.PackageImportTreeViewItem((ImportPackageItem) null, hashCode, depth, parent, displayName); parent.AddChild((TreeViewItem) importTreeViewItem2); parent = (TreeViewItem) importTreeViewItem2; if (initExpandedState) this.m_TreeView.state.expandedIDs.Add(hashCode); treeViewFolders[empty] = importTreeViewItem2; } } } return parent; }