コード例 #1
0
	// Sum Selection: Queries
	// --------------------------------------------------------------------

	public bool InSumSelection(BuildReportTool.SizePart b)
	{
		return _selectedForSum.ContainsKey(b.Name);
	}
コード例 #2
0
        bool DrawColumn(int sta, int end, BuildReportTool.AssetList.SortType columnType, string columnName, bool showScrollbar, BuildReportTool.AssetList assetListCollection, BuildReportTool.SizePart[] assetList, ColumnDisplayDelegate dataToDisplay, ref Vector2 scollbarPos)
        {
            bool buttonPressed = false;
            GUILayout.BeginVertical();

            // ----------------------------------------------------------
            // column header
            string sortTypeStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_STYLE_NAME;
            if (assetListCollection.CurrentSortType == columnType)
            {
            if (assetListCollection.CurrentSortOrder == BuildReportTool.AssetList.SortOrder.Descending)
            {
                sortTypeStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_DESC_STYLE_NAME;
            }
            else
            {
                sortTypeStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_ASC_STYLE_NAME;
            }
            }
            if (GUILayout.Button(columnName, sortTypeStyleName, GUILayout.Height(LIST_HEIGHT)))
            {
            buttonPressed = true;
            }

            // ----------------------------------------------------------
            // scrollbar
            if (showScrollbar)
            {
            scollbarPos = GUILayout.BeginScrollView(scollbarPos,
                BuildReportTool.Window.Settings.HIDDEN_SCROLLBAR_STYLE_NAME, "verticalscrollbar");
            }
            else
            {
            scollbarPos = GUILayout.BeginScrollView(scollbarPos,
                BuildReportTool.Window.Settings.HIDDEN_SCROLLBAR_STYLE_NAME, BuildReportTool.Window.Settings.HIDDEN_SCROLLBAR_STYLE_NAME);
            }

            // ----------------------------------------------------------
            // actual contents
            bool useAlt = false;

            BuildReportTool.SizePart b;
            for (int n = sta; n < end; ++n)
            {
            b = assetList[n];

            string styleToUse = useAlt ? BuildReportTool.Window.Settings.LIST_SMALL_ALT_STYLE_NAME : BuildReportTool.Window.Settings.LIST_SMALL_STYLE_NAME;
            if (assetListCollection.InSumSelection(b))
            {
                styleToUse = BuildReportTool.Window.Settings.LIST_SMALL_SELECTED_NAME;
            }

            GUILayout.Label(dataToDisplay(b), styleToUse, GUILayout.MinWidth(90), GUILayout.Height(LIST_HEIGHT));

            useAlt = !useAlt;
            }

            GUILayout.EndScrollView();

            GUILayout.EndVertical();

            return buttonPressed;
        }
コード例 #3
0
	public void AssignPerCategoryList(BuildReportTool.SizePart[][] perCategory)
	{
		_perCategory = perCategory;
		_viewOffsets = new int[1 + _perCategory.Length];
	}
コード例 #4
0
	static BuildReportTool.SizePart[] GetAllUnusedAssets(
		BuildReportTool.SizePart[] scriptDLLs,
		string projectAssetsPath,
		bool includeSvn, bool includeGit,
		BuildPlatform buildPlatform,
		bool includeUnusedPrefabs,
		int fileCountBatchSkip, int fileCountLimit,
		Dictionary<string, bool> usedAssetsDict,
		List<BuildReportTool.SizePart> inOutAllUsedAssets)
	{
		List<BuildReportTool.SizePart> unusedAssets = new List<BuildReportTool.SizePart>();


		// now loop through all assets in the whole project,
		// check if that file exists in the usedAssetsDict,
		// if not, include it in the unusedAssets list,
		// then sort by size

		int projectStringLen = projectAssetsPath.Length - "Assets".Length;

		bool has32BitPluginsFolder = Directory.Exists(projectAssetsPath + "/Plugins/x86");
		bool has64BitPluginsFolder = Directory.Exists(projectAssetsPath + "/Plugins/x86_64");

		string currentAsset = "";

		int assetIdx = 0;

		int fileCountOffset = fileCountBatchSkip * fileCountLimit;

		foreach (string fullAssetPath in DldUtil.TraverseDirectory.Do(projectAssetsPath))
		{
			++assetIdx;

			if (assetIdx < fileCountOffset)
			{
				continue;
			}

			BRT_BuildReportWindow.GetValueMessage = "Getting list of used assets " + assetIdx + " ...";

			//Debug.Log(fullAssetPath);

			//string fullAssetPath = allAssets[assetIdx];

			currentAsset = fullAssetPath;
			currentAsset = currentAsset.Substring(projectStringLen, currentAsset.Length - projectStringLen);

			// Unity .meta files are not considered part of the assets
			// Unity .mask (Avatar masks): whether a .mask file is used or not currently cannot be reliably found out, so they are skipped
			// anything in a /Resources/ folder will always be in the build, so don't bother checking for it
			if (Util.IsFileOfType(currentAsset, ".meta") || Util.IsFileOfType(currentAsset, ".mask") || Util.IsFileInAPath(currentAsset, "/resources/"))
			{
				continue;
			}

			// include version control files only if requested to do so
			if (!includeSvn && Util.IsFileInAPath(currentAsset, "/.svn/"))
			{
				continue;
			}
			if (!includeGit && Util.IsFileInAPath(currentAsset, "/.git/"))
			{
				continue;
			}

			// NOTE: if a .dll is present in the Script DLLs list, that means
			// it is a managed DLL, and thus, is always used in the build

			if (Util.IsFileOfType(currentAsset, ".dll"))
			{
				string assetFilenameOnly = Path.GetFileName(currentAsset);
				//Debug.Log(assetFilenameOnly);

				bool foundMatch = false;

				// is current asset found in the script DLLs list?
				for (int mdllIdx = 0; mdllIdx < scriptDLLs.Length; ++mdllIdx)
				{
					if (scriptDLLs[mdllIdx].Name == assetFilenameOnly)
					{
						// it's a managed DLL. Managed DLLs are always included in the build.
						foundMatch = true;
						inOutAllUsedAssets.Add(BuildReportTool.Util.CreateSizePartFromFile(currentAsset, fullAssetPath));
						break;
					}
				}

				if (foundMatch)
				{
					continue;
				}
			}


			// per platform special cases
			// involving native plugins

			// in windows and linux, the issue gets dicey as we have to check if its a 32 bit, 64 bit, or universal build

			// so for windows/linux 32 bit, if Assets/Plugins/x86 exists, it will include all dll/so in those. if that folder does not exist, all dll/so in Assets/Plugins are included instead.
			//
			// what if there's a 64 bit dll/so in Assets/Plugins? surely it would not get included in a 32 bit build?

			// for windows/linux 64 bit, if Assets/Plugins/x86_64 exists, it will include all dll/so in those. if that folder does not exist, all dll/so in Assets/Plugins are included instead.

			// right now there is no such thing as a windows universal build

			// For linux universal build, any .so in Assets/Plugins/x86 and Assets/Plugins/x86_64 are included. No .so in Assets/Plugins will be included (as it wouldn't be able to determine if such an .so in that folder is 32 or 64 bit) i.e. it relies on the .so being in the x86 or x86_64 subfolder to determine which is the 32 bit and which is the 64 bit version


			// NOTE: in Unity 3.x there is no Linux build target, but there is Windows 32/64 bit

/*
			from http://docs.unity3d.com/Documentation/Manual/PluginsForDesktop.html

			On Windows and Linux, plugins can be managed manually (e.g, before building a 64-bit player, you copy the 64-bit library into the Assets/Plugins folder, and before building a 32-bit player, you copy the 32-bit library into the Assets/Plugins folder)

				OR you can place the 32-bit version of the plugin in Assets/Plugins/x86 and the 64-bit version of the plugin in Assets/Plugins/x86_64.

			By default the editor will look in the architecture-specific sub-directory first, and if that directory does not exist, it will use plugins from the root Assets/Plugins folder instead.

			Note that for the Universal Linux build, you are required to use the architecture-specific sub-directories (when building a Universal Linux build, the Editor will not copy any plugins from the root Assets/Plugins folder).

			For Mac OS X, you should build your plugin as a universal binary that contains both 32-bit and 64-bit architectures.
*/

			switch (buildPlatform)
			{
				case BuildPlatform.Android:
					// .jar files inside /Assets/Plugins/Android/ are always included in the build if built for Android
					if (Util.IsFileInAPath(currentAsset, "assets/plugins/android/") && (Util.IsFileOfType(currentAsset, ".jar") || Util.IsFileOfType(currentAsset, ".so")))
					{
						//Debug.Log(".jar file in android " + currentAsset);
						inOutAllUsedAssets.Add(BuildReportTool.Util.CreateSizePartFromFile(currentAsset, fullAssetPath));
						continue;
					}
					break;

				case BuildPlatform.iOS:
					if (Util.IsFileOfType(currentAsset, ".a") || Util.IsFileOfType(currentAsset, ".m") || Util.IsFileOfType(currentAsset, ".mm") || Util.IsFileOfType(currentAsset, ".c") || Util.IsFileOfType(currentAsset, ".cpp"))
					{
						// any .a, .m, .mm, .c, or .cpp files inside Assets/Plugins/iOS are automatically symlinked/used
						if (Util.IsFileInAPath(currentAsset, "assets/plugins/ios/"))
						{
							inOutAllUsedAssets.Add(BuildReportTool.Util.CreateSizePartFromFile(currentAsset, fullAssetPath));
						}
						// if there are any .a, .m, .mm, .c, or .cpp files outside of Assets/Plugins/iOS
						// we can't determine if they are really used or not because the user may manually copy them to the Xcode project, or a post-process .sh script may copy them to the Xcode project.
						// so we don't put them in the unused assets list
						continue;
					}
					break;



				case BuildPlatform.MacOSX32:
					// when in mac build, .bundle files that are in Assets/Plugins are always included
					// supposedly, Unity expects all .bundle files as universal builds (even if this is only a 32-bit build?)
					if (Util.IsFileInAPath(currentAsset, "assets/plugins/") && Util.IsFileOfType(currentAsset, ".bundle"))
					{
						inOutAllUsedAssets.Add(BuildReportTool.Util.CreateSizePartFromFile(currentAsset, fullAssetPath));
						continue;
					}
					break;
				case BuildPlatform.MacOSX64:
					// when in mac build, .bundle files that are in Assets/Plugins are always included
					// supposedly, Unity expects all .bundle files as universal builds (even if this is only a 64-bit build?)
					if (Util.IsFileInAPath(currentAsset, "assets/plugins/") && Util.IsFileOfType(currentAsset, ".bundle"))
					{
						inOutAllUsedAssets.Add(BuildReportTool.Util.CreateSizePartFromFile(currentAsset, fullAssetPath));
						continue;
					}
					break;
				case BuildPlatform.MacOSXUniversal:
					// when in mac build, .bundle files that are in Assets/Plugins are always included
					// supposedly, Unity expects all .bundle files as universal builds
					if (Util.IsFileInAPath(currentAsset, "assets/plugins/") && Util.IsFileOfType(currentAsset, ".bundle"))
					{
						inOutAllUsedAssets.Add(BuildReportTool.Util.CreateSizePartFromFile(currentAsset, fullAssetPath));
						continue;
					}
					break;



				case BuildPlatform.Windows32:
					if (Util.IsFileOfType(currentAsset, ".dll"))
					{
						if (Util.IsFileInAPath(currentAsset, "assets/plugins/x86/"))
						{
							inOutAllUsedAssets.Add(BuildReportTool.Util.CreateSizePartFromFile(currentAsset, fullAssetPath));
							continue;
						}
						// Unity only makes use of Assets/Plugins/ if Assets/Plugins/x86/ does not exist
						else if (Util.IsFileInAPath(currentAsset, "assets/plugins/") && !has32BitPluginsFolder)
						{
							inOutAllUsedAssets.Add(BuildReportTool.Util.CreateSizePartFromFile(currentAsset, fullAssetPath));
							continue;
						}
					}
					break;

				case BuildPlatform.Windows64:
					if (Util.IsFileOfType(currentAsset, ".dll"))
					{
						if (Util.IsFileInAPath(currentAsset, "assets/plugins/x86_64/"))
						{
							inOutAllUsedAssets.Add(BuildReportTool.Util.CreateSizePartFromFile(currentAsset, fullAssetPath));
							continue;
						}
						// Unity only makes use of Assets/Plugins/ if Assets/Plugins/x86_64/ does not exist
						else if (Util.IsFileInAPath(currentAsset, "assets/plugins/") && !has64BitPluginsFolder)
						{
							inOutAllUsedAssets.Add(BuildReportTool.Util.CreateSizePartFromFile(currentAsset, fullAssetPath));
							continue;
						}
					}
					break;



				case BuildPlatform.Linux32:
					if (Util.IsFileOfType(currentAsset, ".so"))
					{
						if (Util.IsFileInAPath(currentAsset, "assets/plugins/x86/"))
						{
							inOutAllUsedAssets.Add(BuildReportTool.Util.CreateSizePartFromFile(currentAsset, fullAssetPath));
							continue;
						}
						// Unity only makes use of Assets/Plugins/ if Assets/Plugins/x86/ does not exist
						else if (Util.IsFileInAPath(currentAsset, "assets/plugins/") && !has32BitPluginsFolder)
						{
							inOutAllUsedAssets.Add(BuildReportTool.Util.CreateSizePartFromFile(currentAsset, fullAssetPath));
							continue;
						}
					}
					break;

				case BuildPlatform.Linux64:
					if (Util.IsFileOfType(currentAsset, ".so"))
					{
						if (Util.IsFileInAPath(currentAsset, "assets/plugins/x86_64/"))
						{
							inOutAllUsedAssets.Add(BuildReportTool.Util.CreateSizePartFromFile(currentAsset, fullAssetPath));
							continue;
						}
						// Unity only makes use of Assets/Plugins/ if Assets/Plugins/x86_64/ does not exist
						else if (Util.IsFileInAPath(currentAsset, "assets/plugins/") && !has64BitPluginsFolder)
						{
							inOutAllUsedAssets.Add(BuildReportTool.Util.CreateSizePartFromFile(currentAsset, fullAssetPath));
							continue;
						}
					}
					break;

				case BuildPlatform.LinuxUniversal:
					if (Util.IsFileOfType(currentAsset, ".so"))
					{
						if (Util.IsFileInAPath(currentAsset, "assets/plugins/x86/") || Util.IsFileInAPath(currentAsset, "assets/plugins/x86_64/"))
						{
							inOutAllUsedAssets.Add(BuildReportTool.Util.CreateSizePartFromFile(currentAsset, fullAssetPath));
							continue;
						}
					}
					break;
			}

			// check prefabs only when requested to do so
			if (Util.IsFileOfType(currentAsset, ".prefab"))
			{
				//Debug.Log("GetAllUnusedAssets: found prefab: " + Path.GetFileName(currentAsset));
				if (!includeUnusedPrefabs)
				{
					continue;
				}
			}

			// assets in StreamingAssets folder are always included
			if (Util.IsFileInAPath(currentAsset, "assets/streamingassets"))
			{
				inOutAllUsedAssets.Add(BuildReportTool.Util.CreateSizePartFromFile(currentAsset, fullAssetPath));
				continue;
			}

			// if asset not in used assets list
			if (!usedAssetsDict.ContainsKey(currentAsset))
			{
				// then that simply means this asset is unused
				unusedAssets.Add(BuildReportTool.Util.CreateSizePartFromFile(currentAsset, fullAssetPath));
			}

			if (unusedAssets.Count >= fileCountLimit)
			{
				break;
			}
		}

		return unusedAssets.ToArray();
	}
コード例 #5
0
	void DrawPercentages(BuildReportTool.SizePart[] list)
	{
		GUILayout.BeginVertical();
		bool useAlt = false;
		foreach (BuildReportTool.SizePart b in list)
		{
			if (b.IsTotal) continue;
			string styleToUse = useAlt ? LIST_NORMAL_ALT_STYLE_NAME : LIST_NORMAL_STYLE_NAME;
			GUILayout.Label(b.Percentage + "%", styleToUse);
			useAlt = !useAlt;
		}
		GUILayout.EndVertical();
	}
コード例 #6
0
	public void AddToSumSelection(BuildReportTool.SizePart b)
	{
		_selectedForSum.Add(b.Name, b);
	}
コード例 #7
0
	public static BuildReportTool.SizePart[][] SegregateAssetSizesPerCategory(BuildReportTool.SizePart[] assetSizesAll, FileFilterGroup filters)
	{
		if (assetSizesAll == null || assetSizesAll.Length == 0) return null;

		// we do filters.Count+1 for Unrecognized category
		List< List<BuildReportTool.SizePart> > ret = new List< List<BuildReportTool.SizePart> >(filters.Count+1);
		for (int n = 0, len = filters.Count+1; n < len; ++n)
		{
			ret.Add(new List<BuildReportTool.SizePart>());
		}

		bool foundAtLeastOneMatch = false;
		for (int idxAll = 0, lenAll = assetSizesAll.Length; idxAll < lenAll; ++idxAll)
		{
			BRT_BuildReportWindow.GetValueMessage = "Segregating assets " + (idxAll+1) + " of " + assetSizesAll.Length + "...";

			foundAtLeastOneMatch = false;
			for (int n = 0, len = filters.Count; n < len; ++n)
			{
				if (filters[n].IsFileInFilter(assetSizesAll[idxAll].Name))
				{
					foundAtLeastOneMatch = true;
					ret[n].Add(assetSizesAll[idxAll]);
				}
			}

			if (!foundAtLeastOneMatch)
			{
				ret[ret.Count-1].Add(assetSizesAll[idxAll]);
			}
		}

		BRT_BuildReportWindow.GetValueMessage = "";

		BuildReportTool.SizePart[][] retArr = new BuildReportTool.SizePart[filters.Count+1][];
		for (int n = 0, len = filters.Count+1; n < len; ++n)
		{
			retArr[n] = ret[n].ToArray();
		}

		return retArr;
	}
コード例 #8
0
        void DrawAssetList(BuildReportTool.AssetList assetList)
        {
            BuildReportTool.SizePart[] assetsToShow = assetList.TopTenLargest;

            if (assetsToShow == null)
            {
            Debug.LogError("no top ten largest");
            return;
            }

            bool useAlt = true;

            GUILayout.BeginHorizontal();

            // 1st column: name
            GUILayout.BeginVertical();
            for (int n = 0; n < assetsToShow.Length; ++n)
            {
                BuildReportTool.SizePart b = assetsToShow[n];

                string styleToUse = useAlt ? BuildReportTool.Window.Settings.LIST_NORMAL_ALT_STYLE_NAME : BuildReportTool.Window.Settings.LIST_NORMAL_STYLE_NAME;

                string prettyName = " " + (n+1) + ". " + Path.GetFileName(b.Name);
                Texture icon = AssetDatabase.GetCachedIcon(b.Name);
                if (GUILayout.Button(new GUIContent(prettyName, icon), styleToUse, GUILayout.MinWidth(100), GUILayout.MaxWidth(400), GUILayout.Height(30)))
                {
                    Utility.PingAssetInProject(b.Name);
                }

                useAlt = !useAlt;
            }
            GUILayout.EndVertical();

            // 2nd column: size
            useAlt = true;
            GUILayout.BeginVertical();
            for (int n = 0; n < assetsToShow.Length; ++n)
            {
                BuildReportTool.SizePart b = assetsToShow[n];

                string styleToUse = useAlt ? BuildReportTool.Window.Settings.LIST_NORMAL_ALT_STYLE_NAME : BuildReportTool.Window.Settings.LIST_NORMAL_STYLE_NAME;

                GUILayout.Label(b.RawSize, styleToUse, GUILayout.MaxWidth(100), GUILayout.Height(30));

                useAlt = !useAlt;
            }
            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
コード例 #9
0
	static void SortImportedSize(BuildReportTool.SizePart[] assetList, SortOrder sortOrder)
	{
		if (sortOrder == SortOrder.Descending)
		{
			Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2) {
				if (entry1.ImportedSizeBytes > entry2.ImportedSizeBytes) return -1;
				if (entry1.ImportedSizeBytes < entry2.ImportedSizeBytes) return 1;
				return 0;
			});
		}
		else
		{
			Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2) {
				if (entry1.ImportedSizeBytes > entry2.ImportedSizeBytes) return 1;
				if (entry1.ImportedSizeBytes < entry2.ImportedSizeBytes) return -1;
				return 0;
			});
		}
	}
コード例 #10
0
	public void Init(BuildReportTool.SizePart[] all, BuildReportTool.SizePart[][] perCategory, FileFilterGroup fileFilters)
	{
		_all = all;
		_perCategory = perCategory;

		_viewOffsets = new int[1 + PerCategory.Length];

		RefreshFilterLabels(fileFilters);
	}
コード例 #11
0
 void DrawReadableSizes(BuildReportTool.SizePart[] list)
 {
     GUILayout.BeginVertical();
     bool useAlt = false;
     foreach (BuildReportTool.SizePart b in list)
     {
     if (b.IsTotal) continue;
     string styleToUse = useAlt ? BuildReportTool.Window.Settings.LIST_NORMAL_ALT_STYLE_NAME : BuildReportTool.Window.Settings.LIST_NORMAL_STYLE_NAME;
     GUILayout.Label(b.Size, styleToUse);
     useAlt = !useAlt;
     }
     GUILayout.EndVertical();
 }
コード例 #12
0
    void InitiateDeleteSelectedInAssetList(BuildReportTool.AssetList listToDeleteFrom)
    {
        if (listToDeleteFrom.IsNothingSelected)
        {
            return;
        }

        BuildReportTool.SizePart[] all = listToDeleteFrom.All;

        int numOfFilesRequestedToDelete = listToDeleteFrom.GetSelectedCount();
        int numOfFilesToDelete = numOfFilesRequestedToDelete;
        int systemDeletionFileCount = 0;
        int brtFilesSelectedForDelete = 0;

        // filter out files that shouldn't be deleted
        // and identify unrecoverable files
        for (int n = 0, len = all.Length; n < len; ++n)
        {
            BuildReportTool.SizePart b = all[n];
            bool isThisFileToBeDeleted = listToDeleteFrom.InSumSelection(b);

            if (isThisFileToBeDeleted)
            {
                if (BuildReportTool.Util.IsFileInBuildReportFolder(b.Name) && !BuildReportTool.Util.IsUselessFile(b.Name))
                {
                    //Debug.Log("BRT file? " + b.Name);
                    --numOfFilesToDelete;
                    ++brtFilesSelectedForDelete;
                }
                else if (BuildReportTool.Util.HaveToUseSystemForDelete(b.Name))
                {
                    ++systemDeletionFileCount;
                }
            }
        }

        if (numOfFilesToDelete <= 0)
        {
            if (brtFilesSelectedForDelete > 0)
            {
                EditorApplication.Beep();
                EditorUtility.DisplayDialog("Can't delete!", "Take note that for safety, Build Report Tool assets themselves will not be included for deletion.", "OK");
            }
            return;
        }

        // prepare warning message for user

        bool deletingSystemFilesOnly = (systemDeletionFileCount == numOfFilesToDelete);
        bool deleteIsRecoverable = !deletingSystemFilesOnly;

        string plural = "";
        if (numOfFilesToDelete > 1)
        {
            plural = "s";
        }

        string message = null;

        if (numOfFilesRequestedToDelete != numOfFilesToDelete)
        {
            message = "Among " + numOfFilesRequestedToDelete + " file" + plural + " requested to be deleted, only " + numOfFilesToDelete + " will be deleted.";
        }
        else
        {
            message = "This will delete " + numOfFilesToDelete + " asset" + plural + " in your project.";
        }

        // add warning about BRT files that are skipped
        if (brtFilesSelectedForDelete > 0)
        {
            message += "\n\nTake note that for safety, " + brtFilesSelectedForDelete + " file" + ((brtFilesSelectedForDelete > 1) ? "s" : "") + " found to be Build Report Tool assets are not included for deletion.";
        }

        // add warning about unrecoverable files
        if (systemDeletionFileCount > 0)
        {
            if (deletingSystemFilesOnly)
            {
                message += "\n\nThe deleted file" + plural + " will not be recoverable from the " + BuildReportTool.Util.NameOfOSTrashFolder + ", unless you have your own backup.";
            }
            else
            {
                message += "\n\nAmong the " + numOfFilesToDelete + " file" + plural + " for deletion, " + systemDeletionFileCount + " will not be recoverable from the " + BuildReportTool.Util.NameOfOSTrashFolder + ", unless you have your own backup.";
            }
            message += "\n\nThis is a limitation in Unity and .NET code. To ensure deleting will move the files to the " + BuildReportTool.Util.NameOfOSTrashFolder + " instead, delete your files the usual way using your project view.";
        }
        else
        {
            message += "\n\nThe deleted file" + plural + " can be recovered from your " + BuildReportTool.Util.NameOfOSTrashFolder + ".";
        }

        message += "\n\nDeleting a large number of files may take a long time as Unity will rebuild the project's Library folder.\n\nProceed with deleting?";

        EditorApplication.Beep();
        if (!EditorUtility.DisplayDialog("Delete?", message, "Yes", "No"))
        {
            return;
        }

        List<BuildReportTool.SizePart> allList = new List<BuildReportTool.SizePart>(all);
        List<BuildReportTool.SizePart> toRemove = new List<BuildReportTool.SizePart>(all.Length/4);

        // finally, delete the files
        int deletedCount = 0;
        for (int n = 0, len = allList.Count; n < len; ++n)
        {
            BuildReportTool.SizePart b = allList[n];

            bool okToDelete = BuildReportTool.Util.IsUselessFile(b.Name) || !BuildReportTool.Util.IsFileInBuildReportFolder(b.Name);

            if (listToDeleteFrom.InSumSelection(b) && okToDelete)
            {
                // delete this

                if (BuildReportTool.Util.ShowFileDeleteProgress(deletedCount, numOfFilesToDelete, b.Name, deleteIsRecoverable))
                {
                    return;
                }

                BuildReportTool.Util.DeleteSizePartFile(b);
                toRemove.Add(b);
                ++deletedCount;
            }
        }
        EditorUtility.ClearProgressBar();

        // refresh the asset lists
        allList.RemoveAll(i => toRemove.Contains(i));
        BuildReportTool.SizePart[] allWithRemoved = allList.ToArray();

        // recreate per category list (maybe just remove from existing per category lists instead?)
        BuildReportTool.SizePart[][] perCategoryOfList = BuildReportTool.ReportManager.SegregateAssetSizesPerCategory(allWithRemoved, _buildInfo.FileFilters);

        listToDeleteFrom.Reinit(allWithRemoved, perCategoryOfList);
        listToDeleteFrom.ClearSelection();

        // print info about the delete operation to console
        string finalMessage = deletedCount + " file" + plural + " removed from your project.";
        if (deleteIsRecoverable)
        {
            finalMessage += " They can be recovered from your " + BuildReportTool.Util.NameOfOSTrashFolder + ".";
        }

        EditorApplication.Beep();
        EditorUtility.DisplayDialog("Delete successful", finalMessage, "OK");

        Debug.LogWarning(finalMessage);
    }
コード例 #13
0
    public void Init(BuildReportTool.BuildInfo buildInfo)
    {
        _buildInfo = buildInfo;

        minSize = new Vector2(903, 378);
    }
コード例 #14
0
        void DrawTopBar(Rect position, BuildInfo buildReportToDisplay, BuildReportTool.FileFilterGroup fileFilterGroupToUse)
        {
            BuildReportTool.AssetList assetListUsed = GetAssetListToDisplay(buildReportToDisplay);

            if (assetListUsed == null)
            {
            return;
            }

            Texture2D prevArrow = GUI.skin.GetStyle(BuildReportTool.Window.Settings.BIG_LEFT_ARROW_ICON_STYLE_NAME).normal.background;
            Texture2D nextArrow = GUI.skin.GetStyle(BuildReportTool.Window.Settings.BIG_RIGHT_ARROW_ICON_STYLE_NAME).normal.background;

            GUILayout.BeginHorizontal(GUILayout.Height(11));

            GUILayout.Label(" ", BuildReportTool.Window.Settings.TOP_BAR_BG_STYLE_NAME);

            // ------------------------------------------------------------------------------------------------------
            // File Filters

            fileFilterGroupToUse.Draw(assetListUsed, position.width - 100);

            // ------------------------------------------------------------------------------------------------------

            GUILayout.Space(20);

            // ------------------------------------------------------------------------------------------------------
            // Unused Assets Batch

            if (IsShowingUnusedAssets)
            {
                int batchNumber = buildReportToDisplay.UnusedAssetsBatchNum + 1;

                if (GUILayout.Button(prevArrow, BuildReportTool.Window.Settings.TOP_BAR_BTN_STYLE_NAME) && (batchNumber - 1 >= 1))
                {
                    // move to previous batch
                    BuildReportTool.ReportGenerator.MoveUnusedAssetsBatchToPrev(buildReportToDisplay, fileFilterGroupToUse);
                }

                string batchLabel = "Batch " + batchNumber;
                GUILayout.Label(batchLabel, BuildReportTool.Window.Settings.TOP_BAR_LABEL_STYLE_NAME);

                if (GUILayout.Button(nextArrow, BuildReportTool.Window.Settings.TOP_BAR_BTN_STYLE_NAME))
                {
                    // move to next batch
                    // (possible to have no new batch anymore. if so, it will just fail silently)
                    BuildReportTool.ReportGenerator.MoveUnusedAssetsBatchToNext(buildReportToDisplay, fileFilterGroupToUse);
                }
            }

            // ------------------------------------------------------------------------------------------------------

            // ------------------------------------------------------------------------------------------------------
            // Paginate Buttons

            BuildReportTool.SizePart[] assetListToUse = assetListUsed.GetListToDisplay(fileFilterGroupToUse);

            int assetListLength = 0;
            if (assetListToUse != null)
            {
                assetListLength = assetListToUse.Length;
            }

            int viewOffset = assetListUsed.GetViewOffsetForDisplayedList(fileFilterGroupToUse);

            int len = Mathf.Min(viewOffset + BuildReportTool.Options.AssetListPaginationLength, assetListLength);
            int offsetNonZeroBased = viewOffset + (len > 0 ? 1 : 0);

            string NUM_STR = "D" + assetListLength.ToString().Length;

            if (GUILayout.Button(prevArrow, BuildReportTool.Window.Settings.TOP_BAR_BTN_STYLE_NAME) && (viewOffset - BuildReportTool.Options.AssetListPaginationLength >= 0))
            {
                assetListUsed.SetViewOffsetForDisplayedList(fileFilterGroupToUse, viewOffset - BuildReportTool.Options.AssetListPaginationLength);
                _assetListScrollPos.y = 0;
            }

            string paginateLabel = "Page " + offsetNonZeroBased.ToString(NUM_STR) + " - " + len.ToString(NUM_STR) + " of " + assetListLength.ToString(NUM_STR);
            GUILayout.Label(paginateLabel, BuildReportTool.Window.Settings.TOP_BAR_LABEL_STYLE_NAME);

            if (GUILayout.Button(nextArrow, BuildReportTool.Window.Settings.TOP_BAR_BTN_STYLE_NAME) && (viewOffset + BuildReportTool.Options.AssetListPaginationLength < assetListLength))
            {
                assetListUsed.SetViewOffsetForDisplayedList(fileFilterGroupToUse, viewOffset + BuildReportTool.Options.AssetListPaginationLength);
                _assetListScrollPos.y = 0;
            }

            // ------------------------------------------------------------------------------------------------------

            GUILayout.FlexibleSpace();

            // ------------------------------------------------------------------------------------------------------
            // makes sense only for unused assets
            //if (GUILayout.Button(Labels.RECALC_RAW_SIZES, BuildReportTool.Window.Settings.TOP_BAR_BTN_STYLE_NAME))
            //{
            //	assetListUsed.PopulateImportedSizes();
            //}

            if (GUILayout.Button(Labels.RECALC_IMPORTED_SIZES, BuildReportTool.Window.Settings.TOP_BAR_BTN_STYLE_NAME))
            {
                assetListUsed.PopulateImportedSizes();
            }

            // ------------------------------------------------------------------------------------------------------

            // ------------------------------------------------------------------------------------------------------
            // Selection buttons

            if (GUILayout.Button(Labels.SELECT_ALL_LABEL, BuildReportTool.Window.Settings.TOP_BAR_BTN_STYLE_NAME))
            {
                assetListUsed.AddAllDisplayedToSumSelection(fileFilterGroupToUse);
            }
            if (GUILayout.Button(Labels.SELECT_NONE_LABEL, BuildReportTool.Window.Settings.TOP_BAR_BTN_STYLE_NAME))
            {
                assetListUsed.ClearSelection();
            }

            // ------------------------------------------------------------------------------------------------------

            // ------------------------------------------------------------------------------------------------------
            // Delete buttons

            if (ShouldShowDeleteButtons(buildReportToDisplay))
            {
                GUI.backgroundColor = Color.red;
                const string delSelectedLabel = "Delete selected";
                if (GUILayout.Button(delSelectedLabel, BuildReportTool.Window.Settings.TOP_BAR_BTN_STYLE_NAME))
                {
                    InitiateDeleteSelectedUsed(buildReportToDisplay);
                }

                const string deleteAllLabel = "Delete all";
                if (GUILayout.Button(deleteAllLabel, BuildReportTool.Window.Settings.TOP_BAR_BTN_STYLE_NAME))
                {
                    InitiateDeleteAllUnused(buildReportToDisplay);
                }

                GUI.backgroundColor = Color.white;
            }

            // ------------------------------------------------------------------------------------------------------

            GUILayout.EndHorizontal();

            GUILayout.Space(5);
        }
コード例 #15
0
	// Sum Selection: Commands
	// --------------------------------------------------------------------

	public void ToggleSumSelection(BuildReportTool.SizePart b)
	{
		if (InSumSelection(b))
		{
			RemoveFromSumSelection(b);
		}
		else
		{
			AddToSumSelection(b);
		}
	}
コード例 #16
0
	static void SortPercentSize(BuildReportTool.SizePart[] assetList, SortOrder sortOrder)
	{
		if (sortOrder == SortOrder.Descending)
		{
			Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2) {
				if (entry1.Percentage > entry2.Percentage) return -1;
				if (entry1.Percentage < entry2.Percentage) return 1;
				return 0;
			});
		}
		else
		{
			Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2) {
				if (entry1.Percentage > entry2.Percentage) return 1;
				if (entry1.Percentage < entry2.Percentage) return -1;
				return 0;
			});
		}
	}
コード例 #17
0
	public void RemoveFromSumSelection(BuildReportTool.SizePart b)
	{
		_selectedForSum.Remove(b.Name);
	}
コード例 #18
0
	static void SortAssetName(BuildReportTool.SizePart[] assetList, SortOrder sortOrder)
	{
		if (sortOrder == SortOrder.Descending)
		{
			Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2) {
				string entry1Name = BuildReportTool.Util.GetAssetFilename(entry1.Name);
				string entry2Name = BuildReportTool.Util.GetAssetFilename(entry2.Name);
				
				int result = string.Compare(entry1Name, entry2Name, true);

				return result;
			});
		}
		else
		{
			Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2) {
				string entry1Name = BuildReportTool.Util.GetAssetFilename(entry1.Name);
				string entry2Name = BuildReportTool.Util.GetAssetFilename(entry2.Name);
				
				int result = string.Compare(entry1Name, entry2Name, true);

				// invert the result
				if (result == 1) return -1;
				if (result == -1) return 1;
				return 0;
			});
		}
	}
コード例 #19
0
	static void ParseDLLs(string editorLogPath, bool wasWebBuild, string buildFilePath, string projectAssetsPath, string editorAppContentsPath, ApiCompatibilityLevel monoLevel, StrippingLevel codeStrippingLevel, out BuildReportTool.SizePart[] includedDLLs, out BuildReportTool.SizePart[] scriptDLLs)
	{
		List<BuildReportTool.SizePart> includedDLLsList = new List<BuildReportTool.SizePart>();
		List<BuildReportTool.SizePart> scriptDLLsList = new List<BuildReportTool.SizePart>();

		string buildManagedDLLsFolder = BuildReportTool.Util.GetBuildManagedFolder(buildFilePath);
		string buildScriptDLLsFolder = buildManagedDLLsFolder;
		string buildManagedDLLsFolderHigherPriority = "";

		bool wasAndroidApkBuild = buildFilePath.EndsWith(".apk");

		if (wasWebBuild)
		{
			string tryPath;
			bool success = BuildReportTool.Util.AttemptGetWebTempStagingArea(projectAssetsPath, out tryPath);
			if (success)
			{
				buildManagedDLLsFolder = tryPath;
				buildScriptDLLsFolder = tryPath;
			}
		}
		else if (wasAndroidApkBuild)
		{
			string tryPath;
			bool success = BuildReportTool.Util.AttemptGetAndroidTempStagingArea(projectAssetsPath, out tryPath);
			if (success)
			{
				buildManagedDLLsFolder = tryPath;
				buildScriptDLLsFolder = tryPath;
			}
		}

		string unityFolderManagedDLLs;
		bool unityfoldersSuccess = BuildReportTool.Util.AttemptGetUnityFolderMonoDLLs(wasWebBuild, wasAndroidApkBuild, editorAppContentsPath, monoLevel, codeStrippingLevel, out unityFolderManagedDLLs, out buildManagedDLLsFolderHigherPriority);


		//Debug.Log("buildManagedDLLsFolder: " + buildManagedDLLsFolder);
		//Debug.Log("Application.dataPath: " + Application.dataPath);

		if (unityfoldersSuccess && (string.IsNullOrEmpty(buildManagedDLLsFolder) || !Directory.Exists(buildManagedDLLsFolder)))
		{
#if BRT_SHOW_MINOR_WARNINGS
			Debug.LogWarning("Could not find build folder. Using Unity install folder instead for getting mono DLL file sizes.");
#endif
			buildManagedDLLsFolder = unityFolderManagedDLLs;
		}

#if BRT_SHOW_MINOR_WARNINGS
		if (!Directory.Exists(buildManagedDLLsFolder))
		{
			Debug.LogWarning("Could not find folder for getting DLL file sizes. Got: \"" + buildManagedDLLsFolder + "\"");
		}
#endif


		const string PREFIX_REMOVE = "Dependency assembly - ";

		BuildReportTool.SizePart inPart;


		const string MONO_DLL_KEY = "Mono dependencies included in the build";


		foreach (string line in DldUtil.BigFileReader.ReadFile(editorLogPath, MONO_DLL_KEY))
		{
			// blank line signifies end of dll list
			if (string.IsNullOrEmpty(line) || line == "\n" || line == "\r\n")
			{
				break;
			}
			if (line.IndexOf(MONO_DLL_KEY) != -1)
			{
				continue;
			}

			string filename = line;

			filename = BuildReportTool.Util.RemovePrefix(PREFIX_REMOVE, filename);


			string filepath;
			if (BuildReportTool.Util.IsAScriptDLL(filename))
			{
				filepath = buildScriptDLLsFolder + filename;
				//Debug.LogWarning("Script \"" + filepath + "\".");
			}
			else
			{
				filepath = buildManagedDLLsFolder + filename;

				if (!File.Exists(filepath) && unityfoldersSuccess && (buildManagedDLLsFolder != unityFolderManagedDLLs))
				{
#if BRT_SHOW_MINOR_WARNINGS
					Debug.LogWarning("Failed to find file \"" + filepath + "\". Attempting to get from Unity folders.");
#endif
					filepath = unityFolderManagedDLLs + filename;

					if (!string.IsNullOrEmpty(buildManagedDLLsFolderHigherPriority) && File.Exists(buildManagedDLLsFolderHigherPriority + filename))
					{
						filepath = buildManagedDLLsFolderHigherPriority + filename;
					}
				}
			}

			if ((buildManagedDLLsFolder == unityFolderManagedDLLs) && !string.IsNullOrEmpty(buildManagedDLLsFolderHigherPriority) && File.Exists(buildManagedDLLsFolderHigherPriority + filename))
			{
				filepath = buildManagedDLLsFolderHigherPriority + filename;
			}

			//Debug.Log(filename + " " + filepath);

			inPart = BuildReportTool.Util.CreateSizePartFromFile(filename, filepath);

			//gotTotalSizeBytes += inPart.SizeBytes;

			bool shouldGoInScriptDLLList = BuildReportTool.Util.IsAScriptDLL(filename);

			if (!File.Exists(unityFolderManagedDLLs + filename))
			{
				shouldGoInScriptDLLList = true;
			}

			if (shouldGoInScriptDLLList)
			{
				//gotScriptTotalSizeBytes += inPart.SizeBytes;
				scriptDLLsList.Add(inPart);
			}
			else
			{
				includedDLLsList.Add(inPart);
			}
		}

		// somehow, the editor logfile
		// doesn't include UnityEngine.dll
		// even though it gets included in the final build (for desktop builds)
		//
		// for web builds though, it makes sense not to put UnityEngine.dll in the build. and it isn't.
		// Instead, it's likely residing in the browser plugin to save bandwidth.
		//
		// begs the question though, why not have the whole Mono Web Subset DLLs be
		// installed alongside the Unity web browser plugin?
		// no need to bundle Mono DLLs in the web build itself.
		// would have shaved 1 whole MB when a game uses System.Xml.dll for example
		//
		//if (!wasWebBuild)
		{
			string filename = "UnityEngine.dll";
			string filepath = buildManagedDLLsFolder + filename;

			if (File.Exists(filepath))
			{
				inPart = BuildReportTool.Util.CreateSizePartFromFile(filename, filepath);
				//gotTotalSizeBytes += inPart.SizeBytes;
				includedDLLsList.Add(inPart);
			}
		}


		//Debug.Log("total size: " + EditorUtility.FormatBytes(gotTotalSizeBytes) + " (" + gotTotalSizeBytes + " bytes)");
		//Debug.Log("total assembly size: " + EditorUtility.FormatBytes(gotScriptTotalSizeBytes) + " (" + gotScriptTotalSizeBytes + " bytes)");
		//Debug.Log("total size without assembly: " + EditorUtility.FormatBytes(gotTotalSizeBytes - gotScriptTotalSizeBytes) + " (" + (gotTotalSizeBytes-gotScriptTotalSizeBytes) + " bytes)");


		includedDLLs = includedDLLsList.ToArray();
		scriptDLLs = scriptDLLsList.ToArray();
	}
コード例 #20
0
	// Commands: Initialization
	// ==================================================================================

	public void Init(BuildReportTool.SizePart[] all, BuildReportTool.SizePart[][] perCategory, FileFilterGroup fileFilters)
	{
		All = all;
		_perCategory = perCategory;

		_viewOffsets = new int[1 + PerCategory.Length];

		if (_currentSortType == SortType.None)
		{
			ToggleSort(SortType.RawSize);
		}
		else
		{
			SetSort(_currentSortType, _currentSortOrder);
		}

		RefreshFilterLabels(fileFilters);
	}
コード例 #21
0
	static BuildReportTool.SizePart[] GetAllUnusedAssets(
		string[] scenesIncludedInProject,
		BuildReportTool.SizePart[] scriptDLLs,
		string projectAssetsPath,
		bool includeSvn, bool includeGit,
		BuildPlatform buildPlatform,
		bool includeUnusedPrefabs,
		int fileCountBatchSkip, int fileCountLimit,
		List<BuildReportTool.SizePart> inOutAllUsedAssets)
	{
		Dictionary<string, bool> usedAssetsDict = new Dictionary<string, bool>();

		for (int n = 0, len = inOutAllUsedAssets.Count; n < len; ++n)
		{
			usedAssetsDict[inOutAllUsedAssets[n].Name] = true;
		}

		// consider scenes used to be part of used assets
		if (scenesIncludedInProject != null)
		{
			for (int n = 0, len = scenesIncludedInProject.Length; n < len; ++n)
			{
				//Debug.Log("scene " + n + ": " + scenesIncludedInProject[n]);
				usedAssetsDict[scenesIncludedInProject[n]] = true;
			}
		}

		return GetAllUnusedAssets(
			scriptDLLs,
			projectAssetsPath,
			includeSvn, includeGit,
			buildPlatform,
			includeUnusedPrefabs,
			fileCountBatchSkip, fileCountLimit,
			usedAssetsDict,
			inOutAllUsedAssets);
	}
コード例 #22
0
	public void Init(BuildReportTool.SizePart[] all, BuildReportTool.SizePart[][] perCategory, FileFilterGroup fileFilters, SortType newSortType, SortOrder newSortOrder)
	{
		_currentSortType = newSortType;
		_currentSortOrder = newSortOrder;

		Init(all, perCategory, fileFilters);
	}
コード例 #23
0
	public void Init(BuildReportTool.BuildInfo buildInfo)
	{
		_buildInfo = buildInfo;
	}
コード例 #24
0
	public void Reinit(BuildReportTool.SizePart[] all, BuildReportTool.SizePart[][] perCategory)
	{
		All = all;
		_perCategory = perCategory;
	}
コード例 #25
0
	void DrawAssetList(BuildReportTool.AssetList list, BuildReportTool.FileFilterGroup filter, int length)
	{
		GUILayout.BeginHorizontal();
			GUILayout.Label(ASSET_SIZE_BREAKDOWN_MSG_PRE_BOLD, INFO_SUBTITLE_STYLE_NAME);
			GUILayout.Label(ASSET_SIZE_BREAKDOWN_MSG_BOLD, INFO_SUBTITLE_BOLD_STYLE_NAME);
			GUILayout.Label(ASSET_SIZE_BREAKDOWN_MSG_POST_BOLD, INFO_SUBTITLE_STYLE_NAME);
			GUILayout.FlexibleSpace();
		GUILayout.EndHorizontal();

		if (list != null)
		{
			BuildReportTool.SizePart[] assetListToUse = list.GetListToDisplay(filter);

			if (assetListToUse != null)
			{
				if (assetListToUse.Length == 0)
				{
					GUILayout.Label(NO_FILES_FOR_THIS_CATEGORY, INFO_TITLE_STYLE_NAME);
				}
				else
				{
					const int LIST_HEIGHT = 20;
					const int ICON_DISPLAY_SIZE = 15;
					EditorGUIUtility.SetIconSize(Vector2.one * ICON_DISPLAY_SIZE);
					bool useAlt = false;

					int viewOffset = list.GetViewOffsetForDisplayedList(filter);

					// if somehow view offset was out of bounds of the SizePart[] array
					// reset it to zero
					if (viewOffset >= assetListToUse.Length)
					{
						list.SetViewOffsetForDisplayedList(filter, 0);
						viewOffset = 0;
					}

					int len = Mathf.Min(viewOffset + length, assetListToUse.Length);

					GUILayout.BeginHorizontal();

					GUILayout.BeginVertical();
						useAlt = false;
						for (int n = viewOffset; n < len; ++n)
						{
							BuildReportTool.SizePart b = assetListToUse[n];

							string styleToUse = useAlt ? LIST_SMALL_ALT_STYLE_NAME : LIST_SMALL_STYLE_NAME;
							bool inSumSelect = list.InSumSelection(b);
							if (inSumSelect)
							{
								styleToUse = LIST_SMALL_SELECTED_NAME;
							}

							GUILayout.BeginHorizontal();
								bool newInSumSelect = GUILayout.Toggle(inSumSelect, "");
								if (inSumSelect != newInSumSelect)
								{
									if (newInSumSelect)
									{
										list.AddToSumSelection(b);
									}
									else
									{
										list.RemoveFromSumSelection(b);
									}
								}
								
								Texture icon = AssetDatabase.GetCachedIcon(b.Name);
								if (GUILayout.Button(new GUIContent((n+1) + ". " + b.Name, icon), styleToUse, GUILayout.Height(LIST_HEIGHT)))
								{
									PingAssetInProject(b.Name);
								}
							GUILayout.EndHorizontal();
							
							useAlt = !useAlt;
						}
					GUILayout.EndVertical();

					GUILayout.BeginVertical();
						useAlt = false;
						for (int n = viewOffset; n < len; ++n)
						{
							BuildReportTool.SizePart b = assetListToUse[n];

							string styleToUse = useAlt ? LIST_SMALL_ALT_STYLE_NAME : LIST_SMALL_STYLE_NAME;
							if (list.InSumSelection(b))
							{
								styleToUse = LIST_SMALL_SELECTED_NAME;
							}

							GUILayout.Label(b.Size, styleToUse, GUILayout.MinWidth(50), GUILayout.Height(LIST_HEIGHT));
							useAlt = !useAlt;
						}
					GUILayout.EndVertical();

					GUILayout.BeginVertical();
						useAlt = false;
						for (int n = viewOffset; n < len; ++n)
						{
							BuildReportTool.SizePart b = assetListToUse[n];

							string styleToUse = useAlt ? LIST_SMALL_ALT_STYLE_NAME : LIST_SMALL_STYLE_NAME;
							if (list.InSumSelection(b))
							{
								styleToUse = LIST_SMALL_SELECTED_NAME;
							}

							string text = b.Percentage + "%";
							if (b.Percentage < 0)
							{
								text = NON_APPLICABLE_PERCENTAGE;
							}

							GUILayout.Label(text, styleToUse, GUILayout.MinWidth(30), GUILayout.Height(LIST_HEIGHT));
							useAlt = !useAlt;
						}
					GUILayout.EndVertical();
					GUILayout.EndHorizontal();
				}
			}
		}
	}
コード例 #26
0
        void DrawAssetList(Rect position, BuildReportTool.AssetList list, BuildReportTool.FileFilterGroup filter, int length)
        {
            if (list != null)
            {
            BuildReportTool.SizePart[] assetListToUse = list.GetListToDisplay(filter);

            if (assetListToUse != null)
            {
                if (assetListToUse.Length == 0)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(10);
                    GUILayout.Label(Labels.NO_FILES_FOR_THIS_CATEGORY_LABEL, BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME);
                    GUILayout.EndHorizontal();
                }
                else
                {
                    EditorGUIUtility.SetIconSize(Vector2.one * ICON_DISPLAY_SIZE);
                    bool useAlt = false;

                    int viewOffset = list.GetViewOffsetForDisplayedList(filter);

                    // if somehow view offset was out of bounds of the SizePart[] array
                    // reset it to zero
                    if (viewOffset >= assetListToUse.Length)
                    {
                        list.SetViewOffsetForDisplayedList(filter, 0);
                        viewOffset = 0;
                    }

                    int len = Mathf.Min(viewOffset + length, assetListToUse.Length);

                    GUILayout.BeginHorizontal();

                    // column: asset path and name
                    GUILayout.BeginVertical();
                        useAlt = false;

                        //GUILayout.Box("", BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_STYLE_NAME, GUILayout.Height(LIST_HEIGHT), GUILayout.Width(position.width));

                        GUILayout.BeginHorizontal();

                        string sortTypeAssetFullPathStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_STYLE_NAME;
                        if (list.CurrentSortType == BuildReportTool.AssetList.SortType.AssetFullPath)
                        {
                            if (list.CurrentSortOrder == BuildReportTool.AssetList.SortOrder.Descending)
                            {
                                sortTypeAssetFullPathStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_DESC_STYLE_NAME;
                            }
                            else
                            {
                                sortTypeAssetFullPathStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_ASC_STYLE_NAME;
                            }
                        }
                        if ( GUILayout.Button("Asset Path", sortTypeAssetFullPathStyleName, GUILayout.Height(LIST_HEIGHT)) )
                        {
                            list.ToggleSort(BuildReportTool.AssetList.SortType.AssetFullPath);
                        }

                        string sortTypeAssetFilenameStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_STYLE_NAME;
                        if (list.CurrentSortType == BuildReportTool.AssetList.SortType.AssetFilename)
                        {
                            if (list.CurrentSortOrder == BuildReportTool.AssetList.SortOrder.Descending)
                            {
                                sortTypeAssetFilenameStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_DESC_STYLE_NAME;
                            }
                            else
                            {
                                sortTypeAssetFilenameStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_ASC_STYLE_NAME;
                            }
                        }
                        if (GUILayout.Button("Asset Filename", sortTypeAssetFilenameStyleName, GUILayout.Height(LIST_HEIGHT)))
                        {
                            list.ToggleSort(BuildReportTool.AssetList.SortType.AssetFilename);
                        }
                        GUILayout.EndHorizontal();

                        _assetListScrollPos = GUILayout.BeginScrollView(_assetListScrollPos, BuildReportTool.Window.Settings.HIDDEN_SCROLLBAR_STYLE_NAME, BuildReportTool.Window.Settings.HIDDEN_SCROLLBAR_STYLE_NAME);

                        for (int n = viewOffset; n < len; ++n)
                        {
                            BuildReportTool.SizePart b = assetListToUse[n];

                            string styleToUse = useAlt ? BuildReportTool.Window.Settings.LIST_SMALL_ALT_STYLE_NAME : BuildReportTool.Window.Settings.LIST_SMALL_STYLE_NAME;
                            bool inSumSelect = list.InSumSelection(b);
                            if (inSumSelect)
                            {
                                styleToUse = BuildReportTool.Window.Settings.LIST_SMALL_SELECTED_NAME;
                            }

                            GUILayout.BeginHorizontal();

                                // checkbox for selecting
                                bool newInSumSelect = GUILayout.Toggle(inSumSelect, "", GUILayout.Width(20));
                                if (inSumSelect != newInSumSelect)
                                {
                                    if (newInSumSelect)
                                    {
                                        list.AddToSumSelection(b);
                                    }
                                    else
                                    {
                                        list.RemoveFromSumSelection(b);
                                    }
                                }

                                // the asset name
                                Texture icon = AssetDatabase.GetCachedIcon(b.Name);

                                string prettyName = string.Empty;

                                prettyName = string.Format(" {0}. <color=#{1}>{2}{3}</color><b>{4}</b>", (n+1), GetPathColor(inSumSelect), BuildReportTool.Util.GetAssetPath(b.Name), BuildReportTool.Util.GetAssetPathToNameSeparator(b.Name), BuildReportTool.Util.GetAssetFilename(b.Name));

                                GUIStyle styleObjToUse = GUI.skin.GetStyle(styleToUse);
                                Color temp = styleObjToUse.normal.textColor;
                                int origLeft = styleObjToUse.padding.left;
                                int origRight = styleObjToUse.padding.right;

                                styleObjToUse.normal.textColor = styleObjToUse.onNormal.textColor;
                                styleObjToUse.padding.right = 0;

                                if (icon == null)
                                {
                                    //GUILayout.BeginHorizontal(styleObjToUse);
                                    GUILayout.Space(15);
                                    //GUILayout.EndHorizontal();
                                }

                                styleObjToUse.normal.textColor = temp;
                                styleObjToUse.padding.left = 2;
                                if (GUILayout.Button(new GUIContent(prettyName, icon), styleObjToUse, GUILayout.Height(LIST_HEIGHT)))
                                {
                                    Utility.PingAssetInProject(b.Name);
                                }
                                styleObjToUse.padding.right = origRight;
                                styleObjToUse.padding.left = origLeft;

                            GUILayout.EndHorizontal();

                            useAlt = !useAlt;
                        }

                        GUILayout.EndScrollView();

                    GUILayout.EndVertical();

                    // column: raw file size
                    bool pressedRawSizeSortBtn = DrawColumn(viewOffset, len, BuildReportTool.AssetList.SortType.RawSize, (IsShowingUnusedAssets ? "Raw Size" : "Size"), false,
                        list, assetListToUse, (b) => { return b.RawSize; }, ref _assetListScrollPos);

                    bool showScrollbarForImportedSize = IsShowingUnusedAssets;
                    // column: imported file size
                    bool pressedImpSizeSortBtn = false;

                    if (IsShowingUnusedAssets)
                    {
                        pressedImpSizeSortBtn = DrawColumn(viewOffset, len, BuildReportTool.AssetList.SortType.ImportedSize, "Imported Size   ", showScrollbarForImportedSize,
                            list, assetListToUse, (b) => { return b.ImportedSize; }, ref _assetListScrollPos);
                    }

                    // column: percentage to total size
                    bool pressedPercentSortBtn = false;

                    if (IsShowingUsedAssets)
                    {
                        pressedPercentSortBtn = DrawColumn(viewOffset, len, BuildReportTool.AssetList.SortType.PercentSize, "Percent   ", true,
                            list, assetListToUse, (b) => {

                                string text = b.Percentage + "%";
                                if (b.Percentage < 0)
                                {
                                    text = Labels.NON_APPLICABLE_PERCENTAGE_LABEL;
                                }
                                return text;

                            }, ref _assetListScrollPos);
                    }

                    if (pressedRawSizeSortBtn)
                    {
                        list.ToggleSort(BuildReportTool.AssetList.SortType.RawSize);
                    }
                    else if (pressedImpSizeSortBtn)
                    {
                        list.ToggleSort(BuildReportTool.AssetList.SortType.ImportedSize);
                    }
                    else if (pressedPercentSortBtn)
                    {
                        list.ToggleSort(BuildReportTool.AssetList.SortType.PercentSize);
                    }

                    GUILayout.EndHorizontal();
                }
            }
            }
        }