private static BuildArtifactsInfo CreateForStandaloneWin(string buildPath, string dataDirectoryOverride) { var dataDirectory = DropExtension(buildPath) + "_Data"; if (!string.IsNullOrEmpty(dataDirectoryOverride)) { dataDirectory = dataDirectoryOverride; } var result = CreateFromFileSystem(dataDirectory, dataDirectory, "StreamingAssets"); result.runtimeSize = result.runtimeSize.uncompressed + GetDirectorySizeNoThrow(ReliablePath.Combine(dataDirectory, "Mono")); // get the exe var additionalRuntimeSize = GetFileSizeNoThrow(buildPath); if (UnityVersionAgnostic.HasStuffInRootForStandaloneBuild) { var directory = ReliablePath.GetDirectoryName(buildPath); additionalRuntimeSize += GetFileSizeNoThrow(ReliablePath.Combine(directory, "UnityPlayer.dll"), logError: false); additionalRuntimeSize += GetFileSizeNoThrow(ReliablePath.Combine(directory, "UnityCrashHandler64.exe"), logError: false); additionalRuntimeSize += GetDirectorySizeNoThrow(ReliablePath.Combine(directory, "Mono")); } result.totalSize.uncompressed += additionalRuntimeSize; result.runtimeSize.uncompressed += additionalRuntimeSize; return(result); }
private static string DropExtension(string path) { return(ReliablePath.Combine(ReliablePath.GetDirectoryName(path), ReliablePath.GetFileNameWithoutExtension(path))); }
public void Refresh(IEnumerable <string> allAssets, IEnumerable <AssetInfo> usedAssets) { foreach (var assetPath in allAssets) { string directoryPath; bool isDirectory = true; if (Directory.Exists(assetPath)) { directoryPath = assetPath.TrimEnd('/', '\\'); } else { isDirectory = false; directoryPath = ReliablePath.GetDirectoryName(assetPath); } bool hadSpecialEditorDirectory = false; while (!string.IsNullOrEmpty(directoryPath) && IsInSpecialEditorDirectory(directoryPath)) { hadSpecialEditorDirectory = true; directoryPath = ReliablePath.GetDirectoryName(directoryPath); } // add directory entries while (!string.IsNullOrEmpty(directoryPath)) { var directoryIndex = paths.BinarySearch(directoryPath); if (directoryIndex < 0) { directoryIndex = ~directoryIndex; paths.Insert(directoryIndex, directoryPath); entries.Insert(directoryIndex, new DirectoryEntry()); } if (!isDirectory) { if (hadSpecialEditorDirectory) { ++entries[directoryIndex].editorAssetsCount; } else { ++entries[directoryIndex].assetsCount; } } entries[directoryIndex].hadSpecialEditorDirectory |= hadSpecialEditorDirectory; directoryPath = ReliablePath.GetDirectoryName(directoryPath); } } // now do the count foreach (var asset in usedAssets) { var guid = AssetDatabase.AssetPathToGUID(asset.path); if (IsInSpecialEditorDirectory(asset.path)) { continue; } if (string.IsNullOrEmpty(guid)) { continue; } var directoryPath = ReliablePath.GetDirectoryName(asset.path); while (!string.IsNullOrEmpty(directoryPath)) { var directoryIndex = paths.BinarySearch(directoryPath); if (directoryIndex >= 0) { ++entries[directoryIndex].usedAssetsCount; entries[directoryIndex].size += asset.size; directoryPath = ReliablePath.GetDirectoryName(directoryPath); } else { break; } } } }