public PackageImportTreeView(PackageImport packageImport, TreeViewState treeViewState, Rect startRect) { this.m_PackageImport = packageImport; this.m_TreeView = new TreeView((EditorWindow) this.m_PackageImport, treeViewState); PackageImportTreeView.PackageImportTreeViewDataSource treeViewDataSource = new PackageImportTreeView.PackageImportTreeViewDataSource(this.m_TreeView, this); PackageImportTreeView.PackageImportTreeViewGUI importTreeViewGui = new PackageImportTreeView.PackageImportTreeViewGUI(this.m_TreeView, this); this.m_TreeView.Init(startRect, (ITreeViewDataSource) treeViewDataSource, (ITreeViewGUI) importTreeViewGui, (ITreeViewDragging) null); this.m_TreeView.ReloadData(); this.m_TreeView.selectionChangedCallback += new System.Action<int[]>(this.SelectionChanged); importTreeViewGui.itemWasToggled += new System.Action<PackageImportTreeView.PackageImportTreeViewItem>(this.ItemWasToggled); this.ComputeEnabledStateForFolders(); }
private static bool IsAllFilePathsValid(ImportPackageItem[] assetItems, out string errorMessage) { bool result; for (int i = 0; i < assetItems.Length; i++) { ImportPackageItem importPackageItem = assetItems[i]; if (!importPackageItem.isFolder) { char c; int num; if (PackageImport.HasInvalidCharInFilePath(importPackageItem.destinationAssetPath, out c, out num)) { errorMessage = string.Format("Invalid character found in file path: '{0}'. Invalid ascii value: {1} (at character index {2}).", importPackageItem.destinationAssetPath, (int)c, num); result = false; return(result); } } } errorMessage = ""; result = true; return(result); }
private void TopArea() { if ((UnityEngine.Object)PackageImport.s_PackageIcon == (UnityEngine.Object)null && !string.IsNullOrEmpty(this.m_PackageIconPath)) { PackageImport.LoadTexture(this.m_PackageIconPath, ref PackageImport.s_PackageIcon); } bool flag = (UnityEngine.Object)PackageImport.s_PackageIcon != (UnityEngine.Object)null; Rect rect = GUILayoutUtility.GetRect(this.position.width, !flag ? 52f : 84f); GUI.Label(rect, GUIContent.none, PackageImport.ms_Constants.topBarBg); Rect position; if (flag) { Rect r = new Rect(rect.x + 10f, rect.y + 10f, 64f, 64f); PackageImport.DrawTexture(r, PackageImport.s_PackageIcon, true); position = new Rect(r.xMax + 10f, r.yMin, rect.width, r.height); } else { position = new Rect(rect.x + 5f, rect.yMin, rect.width, rect.height); } GUI.Label(position, this.m_PackageName, PackageImport.ms_Constants.title); }
public override void OnGUI(Rect rect) { PackageImport.DrawTexture(rect, this.m_Preview, false); }
public override void FetchData() { int rootDepth = -1; // -1 so its children will have 0 depth m_RootItem = new PackageImportTreeViewItem(null, "Assets".GetHashCode(), rootDepth, null, "InvisibleAssetsFolder"); bool initExpandedState = true; if (initExpandedState) { m_TreeView.state.expandedIDs.Add(m_RootItem.id); } ImportPackageItem[] items = m_PackageImportView.packageItems; Dictionary <string, TreeViewItem> treeViewFolders = new Dictionary <string, TreeViewItem>(); for (int i = 0; i < items.Length; i++) { var item = items[i]; if (PackageImport.HasInvalidCharInFilePath(item.destinationAssetPath)) { continue; // Do not add invalid paths (we already warn the user with a dialog in PackageImport.cs) } string filename = Path.GetFileName(item.destinationAssetPath).ConvertSeparatorsToUnity(); string folderPath = Path.GetDirectoryName(item.destinationAssetPath).ConvertSeparatorsToUnity(); // Ensure folders. This is for when installed packages have been moved to other folders. TreeViewItem targetFolder; treeViewFolders.TryGetValue(folderPath, out targetFolder); if (targetFolder == null) { targetFolder = EnsureFolderPath(folderPath, treeViewFolders, initExpandedState); } // Add file to folder if (targetFolder != null) { int id = item.destinationAssetPath.GetHashCode(); var newItem = new PackageImportTreeViewItem(item, id, targetFolder.depth + 1, targetFolder, filename); targetFolder.AddChild(newItem); if (initExpandedState) { m_TreeView.state.expandedIDs.Add(id); } // We need to ensure that the folder is available for // EnsureFolderPath on subsequent iterations. if (item.isFolder) { treeViewFolders[item.destinationAssetPath] = newItem; } } } if (initExpandedState) { m_TreeView.state.expandedIDs.Sort(); } }
public PackageImportTreeView(AssetsItem[] items, List <string> enabledFolders, TreeViewState treeViewState, PackageImport packageImportWindow, Rect startRect) { this.m_TreeView = new TreeView(packageImportWindow, treeViewState); PackageImportTreeView.PackageImportTreeViewDataSource data = new PackageImportTreeView.PackageImportTreeViewDataSource(this.m_TreeView, items, enabledFolders); PackageImportTreeView.PackageImportTreeViewGUI packageImportTreeViewGUI = new PackageImportTreeView.PackageImportTreeViewGUI(this.m_TreeView); this.m_TreeView.Init(startRect, data, packageImportTreeViewGUI, null); this.m_TreeView.ReloadData(); TreeView expr_5A = this.m_TreeView; expr_5A.selectionChangedCallback = (Action <int[]>)Delegate.Combine(expr_5A.selectionChangedCallback, new Action <int[]>(this.SelectionChanged)); PackageImportTreeView.PackageImportTreeViewGUI expr_7C = packageImportTreeViewGUI; expr_7C.itemWasToggled = (Action <PackageImportTreeView.PackageImportTreeViewItem>)Delegate.Combine(expr_7C.itemWasToggled, new Action <PackageImportTreeView.PackageImportTreeViewItem>(this.ItemWasToggled)); this.ComputeEnabledStateForFolders(); }
private void ShowImportWindow(ImportPackageItem[] items) { m_ImportWindow = PackageImport.GetWindow <PackageImport>(true, "Import Unity Package"); m_ImportWindow.Init(m_PackagePath, items, m_PackageIconPath); }
public PackageImportTreeView(AssetsItem[] items, List<string> enabledFolders, TreeViewState treeViewState, PackageImport packageImportWindow, Rect startRect) { this.m_TreeView = new TreeView(packageImportWindow, treeViewState); PackageImportTreeView.PackageImportTreeViewDataSource data = new PackageImportTreeView.PackageImportTreeViewDataSource(this.m_TreeView, items, enabledFolders); PackageImportTreeView.PackageImportTreeViewGUI packageImportTreeViewGUI = new PackageImportTreeView.PackageImportTreeViewGUI(this.m_TreeView); this.m_TreeView.Init(startRect, data, packageImportTreeViewGUI, null); this.m_TreeView.ReloadData(); TreeView expr_5A = this.m_TreeView; expr_5A.selectionChangedCallback = (Action<int[]>)Delegate.Combine(expr_5A.selectionChangedCallback, new Action<int[]>(this.SelectionChanged)); PackageImportTreeView.PackageImportTreeViewGUI expr_7C = packageImportTreeViewGUI; expr_7C.itemWasToggled = (Action<PackageImportTreeView.PackageImportTreeViewItem>)Delegate.Combine(expr_7C.itemWasToggled, new Action<PackageImportTreeView.PackageImportTreeViewItem>(this.ItemWasToggled)); this.ComputeEnabledStateForFolders(); }