Пример #1
0
 public void AddAssetItems(AssetsItem[] assets)
 {
     foreach (AssetsItem item in assets)
     {
         this.AddAssetItem(item.guid, item.pathName, item.assetIsDir != 0, (ChangeFlags) item.changeFlags, -1);
     }
     if (<>f__mg$cache0 == null)
     {
Пример #2
0
		public static void ShowImportPackage(string packagePath, AssetsItem[] items, string packageIconPath)
		{
			if (!PackageImport.ValidateInput(items))
			{
				return;
			}
			PackageImport window = EditorWindow.GetWindow<PackageImport>(true, "Importing package");
			window.Init(packagePath, items, packageIconPath);
		}
Пример #3
0
 public void AddAssetItems(AssetsItem[] assets)
 {
     foreach (AssetsItem item in assets)
     {
         this.AddAssetItem(item.guid, item.pathName, item.assetIsDir != 0, (ChangeFlags) item.changeFlags, -1);
     }
     Array.Sort<ParentViewFolder>(this.folders, new Comparison<ParentViewFolder>(ParentViewState.CompareViewFolder));
     for (int i = 0; i < this.folders.Length; i++)
     {
         Array.Sort<ParentViewFile>(this.folders[i].files, new Comparison<ParentViewFile>(ParentViewState.CompareViewFile));
     }
 }
Пример #4
0
 public void AddAssetItems(AssetsItem[] assets)
 {
     for (int i = 0; i < assets.Length; i++)
     {
         AssetsItem assetsItem = assets[i];
         this.AddAssetItem(assetsItem.guid, assetsItem.pathName, assetsItem.assetIsDir != 0, (ChangeFlags)assetsItem.changeFlags, -1);
     }
     Array.Sort <ParentViewFolder>(this.folders, new Comparison <ParentViewFolder>(ParentViewState.CompareViewFolder));
     for (int j = 0; j < this.folders.Length; j++)
     {
         Array.Sort <ParentViewFile>(this.folders[j].files, new Comparison <ParentViewFile>(ParentViewState.CompareViewFile));
     }
 }
Пример #5
0
 private void CheckChildren(AssetsItem parentAI)
 {
     AssetsItem[] assets = this.m_assets;
     for (int i = 0; i < assets.Length; i++)
     {
         AssetsItem assetsItem = assets[i];
         if (assetsItem.parentGuid == parentAI.guid)
         {
             assetsItem.enabled = parentAI.enabled;
             this.CheckChildren(assetsItem);
         }
     }
 }
            public override void FetchData()
            {
                this.m_RootItem = new PackageImportTreeView.PackageImportTreeViewItem("Assets".GetHashCode(), 0, null, "InvisibleAssetsFolder");
                ((PackageImportTreeView.PackageImportTreeViewItem) this.m_RootItem).isFolder = true;
                bool flag = this.m_TreeView.state.expandedIDs.Count == 0;

                if (flag)
                {
                    this.m_TreeView.state.expandedIDs.Add(this.m_RootItem.id);
                }
                Dictionary <string, AssetsItem> dictionary = new Dictionary <string, AssetsItem>();

                AssetsItem[] assetItems = this.m_AssetItems;
                for (int i = 0; i < assetItems.Length; i++)
                {
                    AssetsItem assetsItem = assetItems[i];
                    if (assetsItem.assetIsDir == 1)
                    {
                        dictionary[assetsItem.pathName] = assetsItem;
                    }
                }
                Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem> treeViewFolders = new Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem>();

                AssetsItem[] assetItems2 = this.m_AssetItems;
                for (int j = 0; j < assetItems2.Length; j++)
                {
                    AssetsItem assetsItem2 = assetItems2[j];
                    if (assetsItem2.assetIsDir != 1)
                    {
                        if (!PackageImport.HasInvalidCharInFilePath(assetsItem2.pathName))
                        {
                            string       fileName      = Path.GetFileName(assetsItem2.pathName);
                            string       directoryName = Path.GetDirectoryName(assetsItem2.pathName);
                            TreeViewItem treeViewItem  = this.EnsureFolderPath(directoryName, dictionary, treeViewFolders, flag);
                            if (treeViewItem != null)
                            {
                                int hashCode = assetsItem2.pathName.GetHashCode();
                                treeViewItem.AddChild(new PackageImportTreeView.PackageImportTreeViewItem(hashCode, treeViewItem.depth + 1, treeViewItem, fileName)
                                {
                                    item = assetsItem2
                                });
                            }
                        }
                    }
                }
                if (flag)
                {
                    this.m_TreeView.state.expandedIDs.Sort();
                }
            }
Пример #7
0
 private static bool IsAllFilePathsValid(AssetsItem[] assetItems, out string errorMessage)
 {
     for (int i = 0; i < assetItems.Length; i++)
     {
         AssetsItem assetsItem = assetItems[i];
         if (assetsItem.assetIsDir != 1)
         {
             char c;
             int  num;
             if (PackageImport.HasInvalidCharInFilePath(assetsItem.pathName, out c, out num))
             {
                 errorMessage = string.Format("Invalid character found in file path: '{0}'. Invalid ascii value: {1} (at character index {2}).", assetsItem.pathName, (int)c, num);
                 return(false);
             }
         }
     }
     errorMessage = string.Empty;
     return(true);
 }
Пример #8
0
        private void Export()
        {
            string text = EditorUtility.SaveFilePanel("Export package ...", string.Empty, string.Empty, "unitypackage");

            if (text != string.Empty)
            {
                List <string> list   = new List <string>();
                AssetsItem[]  assets = this.m_assets;
                for (int i = 0; i < assets.Length; i++)
                {
                    AssetsItem assetsItem = assets[i];
                    if (assetsItem.enabled != 0)
                    {
                        list.Add(assetsItem.guid);
                    }
                }
                AssetServer.ExportPackage(list.ToArray(), text);
                base.Close();
                GUIUtility.ExitGUI();
            }
        }
Пример #9
0
		public void AddAssetItems(AssetsItem[] assets)
		{
			for (int i = 0; i < assets.Length; i++)
			{
				AssetsItem assetsItem = assets[i];
				this.AddAssetItem(assetsItem.guid, assetsItem.pathName, assetsItem.assetIsDir != 0, (ChangeFlags)assetsItem.changeFlags, -1);
			}
			ParentViewFolder[] arg_66_0 = this.folders;
			if (ParentViewState.<>f__mg$cache0 == null)
			{
				ParentViewState.<>f__mg$cache0 = new Comparison<ParentViewFolder>(ParentViewState.CompareViewFolder);
			}
			Array.Sort<ParentViewFolder>(arg_66_0, ParentViewState.<>f__mg$cache0);
			for (int j = 0; j < this.folders.Length; j++)
			{
				ParentViewFile[] arg_9C_0 = this.folders[j].files;
				if (ParentViewState.<>f__mg$cache1 == null)
				{
					ParentViewState.<>f__mg$cache1 = new Comparison<ParentViewFile>(ParentViewState.CompareViewFile);
				}
				Array.Sort<ParentViewFile>(arg_9C_0, ParentViewState.<>f__mg$cache1);
			}
		}
Пример #10
0
		private static bool IsAllFilePathsValid(AssetsItem[] assetItems, out string errorMessage)
		{
			for (int i = 0; i < assetItems.Length; i++)
			{
				AssetsItem assetsItem = assetItems[i];
				if (assetsItem.assetIsDir != 1)
				{
					char c;
					int num;
					if (PackageImport.HasInvalidCharInFilePath(assetsItem.pathName, out c, out num))
					{
						errorMessage = string.Format("Invalid character found in file path: '{0}'. Invalid ascii value: {1} (at character index {2}).", assetsItem.pathName, (int)c, num);
						return false;
					}
				}
			}
			errorMessage = string.Empty;
			return true;
		}
Пример #11
0
		private static bool ValidateInput(AssetsItem[] items)
		{
			string text;
			if (!PackageImport.IsAllFilePathsValid(items, out text))
			{
				text += "\nDo you want to import the valid file paths of the package or cancel importing?";
				return EditorUtility.DisplayDialog("Invalid file path found", text, "Import", "Cancel importing");
			}
			return true;
		}
Пример #12
0
		private void CheckChildren(AssetsItem parentAI)
		{
			AssetsItem[] assets = this.m_assets;
			for (int i = 0; i < assets.Length; i++)
			{
				AssetsItem assetsItem = assets[i];
				if (assetsItem.parentGuid == parentAI.guid)
				{
					assetsItem.enabled = parentAI.enabled;
					this.CheckChildren(assetsItem);
				}
			}
		}
			public PackageImportTreeViewDataSource(TreeView treeView, AssetsItem[] assetItems, List<string> enabledFolders) : base(treeView)
			{
				this.m_AssetItems = assetItems;
				this.m_EnabledFolders = enabledFolders;
				base.rootIsCollapsable = false;
				base.showRootNode = false;
			}
Пример #14
0
 public void OnGUI()
 {
     if (PackageExport.ms_Constants == null)
     {
         PackageExport.ms_Constants = new PackageExport.Constants();
     }
     if (this.m_assets == null)
     {
         return;
     }
     if (this.m_LeastIndent == 999999)
     {
         int num = this.m_LeastIndent;
         for (int i = 0; i < this.m_assets.Length; i++)
         {
             int num2 = PackageExport.CountOccurencesOfChar(this.m_assets[i].pathName, '/');
             if (num > num2)
             {
                 num = num2;
             }
         }
         this.m_LeastIndent = num - 1;
     }
     if (this.m_assets != null)
     {
         this.SetupListView();
         bool flag = Event.current.type == EventType.Repaint;
         GUILayout.BeginVertical(new GUILayoutOption[0]);
         GUILayout.Label("Items to Export", PackageExport.ms_Constants.title, new GUILayoutOption[0]);
         GUILayout.Space(1f);
         EditorGUIUtility.SetIconSize(new Vector2(16f, 16f));
         foreach (ListViewElement listViewElement in ListViewGUI.ListView(this.m_ListView, GUIStyle.none, new GUILayoutOption[0]))
         {
             AssetsItem assetsItem = this.m_assets[listViewElement.row];
             Rect       position   = listViewElement.position;
             position = new Rect(position.x + 1f, position.y, position.width - 2f, position.height);
             int num3 = PackageExport.CountOccurencesOfChar(assetsItem.pathName, '/') - this.m_LeastIndent;
             if (flag && this.m_ListView.row == listViewElement.row)
             {
                 PackageExport.ms_Constants.ConsoleEntryBackEven.Draw(position, false, false, true, false);
             }
             float y = listViewElement.position.y;
             position.x += 3f;
             int enabled = assetsItem.enabled;
             assetsItem.enabled = ((!GUI.Toggle(new Rect(position.x, position.y, 16f, 16f), assetsItem.enabled != 0, string.Empty)) ? 0 : 1);
             if (enabled != assetsItem.enabled)
             {
                 this.m_ListView.row        = listViewElement.row;
                 GUIUtility.keyboardControl = this.m_ListView.ID;
                 this.CheckChildren(assetsItem);
             }
             if (flag)
             {
                 Rect    position2  = new Rect(position.x + (float)(15 * num3), y + 1f, 16f, 16f);
                 Texture cachedIcon = AssetDatabase.GetCachedIcon(assetsItem.pathName);
                 if (cachedIcon != null)
                 {
                     GUI.DrawTexture(position2, cachedIcon);
                 }
             }
             position = new Rect(position.x + 20f + (float)(15 * num3), listViewElement.position.y, position.width - (float)(20 + 15 * num3), position.height);
             GUI.Label(position, assetsItem.pathName);
         }
         this.FrameLastGUIRect();
         GUILayout.EndVertical();
         if (this.m_ListView.row != -1 && GUIUtility.keyboardControl == this.m_ListView.ID && Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Space)
         {
             this.m_assets[this.m_ListView.row].enabled = ((this.m_assets[this.m_ListView.row].enabled != 0) ? 0 : 1);
             this.CheckChildren(this.m_assets[this.m_ListView.row]);
             Event.current.Use();
         }
         EditorGUIUtility.SetIconSize(Vector2.zero);
         GUILayout.Space(5f);
         GUILayout.BeginHorizontal(new GUILayoutOption[0]);
         GUILayout.Space(10f);
         if (GUILayout.Button(EditorGUIUtility.TextContent("All"), new GUILayoutOption[]
         {
             GUILayout.Width(50f)
         }))
         {
             for (int j = 0; j < this.m_assets.Length; j++)
             {
                 this.m_assets[j].enabled = 1;
             }
         }
         if (GUILayout.Button(EditorGUIUtility.TextContent("None"), new GUILayoutOption[]
         {
             GUILayout.Width(50f)
         }))
         {
             for (int k = 0; k < this.m_assets.Length; k++)
             {
                 this.m_assets[k].enabled = 0;
             }
         }
         GUILayout.Space(10f);
         bool flag2 = GUILayout.Toggle(this.m_bIncludeDependencies, "Include dependencies", new GUILayoutOption[0]);
         if (flag2 != this.m_bIncludeDependencies)
         {
             this.m_bIncludeDependencies = flag2;
             this.BuildAssetList();
         }
         GUILayout.FlexibleSpace();
         if (GUILayout.Button(EditorGUIUtility.TextContent("Export..."), new GUILayoutOption[0]))
         {
             this.Export();
             GUIUtility.ExitGUI();
         }
         GUILayout.Space(10f);
         GUILayout.EndHorizontal();
         GUILayout.Space(10f);
     }
 }
Пример #15
0
            private TreeViewItem EnsureFolderPath(string folderPath, Dictionary <string, AssetsItem> packageFolders, Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem> treeViewFolders, bool initExpandedState)
            {
                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;

                for (int i = 0; i < strArray.Length; i++)
                {
                    string displayName = strArray[i];
                    if (key != string.Empty)
                    {
                        key = key + '/';
                    }
                    key = key + displayName;
                    if (key != "Assets")
                    {
                        PackageImportTreeView.PackageImportTreeViewItem item3;
                        int hashCode = key.GetHashCode();
                        if (treeViewFolders.TryGetValue(key, out item3))
                        {
                            rootItem = item3;
                        }
                        else
                        {
                            AssetsItem item5;
                            int        depth = i - 1;
                            PackageImportTreeView.PackageImportTreeViewItem child = new PackageImportTreeView.PackageImportTreeViewItem(hashCode, depth, rootItem, displayName)
                            {
                                isFolder = true
                            };
                            if (packageFolders.TryGetValue(key, out item5))
                            {
                                child.item = item5;
                            }
                            if (child.item == null)
                            {
                                AssetsItem item6 = new AssetsItem {
                                    assetIsDir        = 1,
                                    pathName          = key,
                                    exportedAssetPath = key,
                                    enabled           = (this.m_EnabledFolders != null) ? (!this.m_EnabledFolders.Contains(key) ? 0 : 1) : 1,
                                    guid        = AssetDatabase.AssetPathToGUID(key),
                                    previewPath = string.Empty
                                };
                                child.item        = item6;
                                child.item.exists = !string.IsNullOrEmpty(child.item.guid) ? 1 : 0;
                            }
                            rootItem.AddChild(child);
                            rootItem = child;
                            if (initExpandedState)
                            {
                                base.m_TreeView.state.expandedIDs.Add(hashCode);
                            }
                            treeViewFolders[key] = child;
                        }
                    }
                }
                return(rootItem);
            }
Пример #16
0
		private void Init(string packagePath, AssetsItem[] items, string packageIconPath)
		{
			this.DestroyCreatedIcons();
			this.m_TreeViewState = null;
			this.m_Tree = null;
			this.m_EnabledFolders = null;
			this.m_Assets = items;
			this.m_PackageName = Path.GetFileNameWithoutExtension(packagePath);
			this.m_PackageIconPath = packageIconPath;
			base.Repaint();
		}
		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();
		}
Пример #18
0
		public void AddAssetItems(AssetsItem[] assets)
		{
			for (int i = 0; i < assets.Length; i++)
			{
				AssetsItem assetsItem = assets[i];
				this.AddAssetItem(assetsItem.guid, assetsItem.pathName, assetsItem.assetIsDir != 0, (ChangeFlags)assetsItem.changeFlags, -1);
			}
			Array.Sort<ParentViewFolder>(this.folders, new Comparison<ParentViewFolder>(ParentViewState.CompareViewFolder));
			for (int j = 0; j < this.folders.Length; j++)
			{
				Array.Sort<ParentViewFile>(this.folders[j].files, new Comparison<ParentViewFile>(ParentViewState.CompareViewFile));
			}
		}
 public void AddAssetItems(AssetsItem[] assets)
 {
   foreach (AssetsItem asset in assets)
     this.AddAssetItem(asset.guid, asset.pathName, asset.assetIsDir != 0, (ChangeFlags) asset.changeFlags, -1);
   Array.Sort<ParentViewFolder>(this.folders, new Comparison<ParentViewFolder>(ParentViewState.CompareViewFolder));
   for (int index = 0; index < this.folders.Length; ++index)
     Array.Sort<ParentViewFile>(this.folders[index].files, new Comparison<ParentViewFile>(ParentViewState.CompareViewFile));
 }
Пример #20
0
		public static extern void ImportPackageStep2(AssetsItem[] assets);
Пример #21
0
 private static bool IsAllFilePathsValid(AssetsItem[] assetItems, out string errorMessage)
 {
     foreach (AssetsItem item in assetItems)
     {
         char ch;
         int num2;
         if ((item.assetIsDir != 1) && HasInvalidCharInFilePath(item.pathName, out ch, out num2))
         {
             errorMessage = string.Format("Invalid character found in file path: '{0}'. Invalid ascii value: {1} (at character index {2}).", item.pathName, (int) ch, num2);
             return false;
         }
     }
     errorMessage = string.Empty;
     return true;
 }