void Start() { string size = PublisherUtils.FormatBytes(5ul); //returns "5 B" size = PublisherUtils.FormatBytes(5 * 1024ul); //returns "5 KB" size = PublisherUtils.FormatBytes(15 * 1024ul * 1024ul); //returns "15 MB" size = PublisherUtils.FormatBytes(999 * 1024ul * 1024ul * 1024ul); //returns "999 MB" }
static bool Zip(Store <AppState> store, string buildOutputDir) { var projectDir = Directory.GetParent(Application.dataPath).FullName; var destPath = Path.Combine(projectDir, ZipName); File.Delete(destPath); ZipFile.CreateFromDirectory(buildOutputDir, destPath); FileInfo fileInfo = new FileInfo(destPath); if (fileInfo.Length > ZipFileLimitBytes) { store.Dispatch(new OnErrorAction { errorMsg = string.Format(Localization.Tr("ERROR_MAX_SIZE"), PublisherUtils.FormatBytes(ZipFileLimitBytes)) }); return(false); } store.Dispatch(new ZipPathChangeAction { zipPath = destPath }); return(true); }
void SetupBuildContainer(VisualElement container, string buildPath) { if (PublisherUtils.BuildIsValid(buildPath)) { string gameTitle = GetGameTitleFromPath(buildPath); SetupButton("btnOpenFolder", () => OnOpenBuildFolderClicked(buildPath), true, container, Localization.Tr("UPLOAD_CONTAINER_BUTTON_OPEN_TOOLTIP")); SetupButton("btnDelete", () => OnDeleteClicked(buildPath, gameTitle), true, container, Localization.Tr("UPLOAD_CONTAINER_BUTTON_DELETE_TOOLTIP")); SetupButton("btnShare", () => OnPublishClicked(buildPath, gameTitle), true, container, Localization.Tr("UPLOAD_CONTAINER_BUTTON_PUBLISH_TOOLTIP"), "UPLOAD_CONTAINER_BUTTON_PUBLISH", true); SetupLabel("lblLastBuildInfo", string.Format(Localization.Tr("UPLOAD_CONTAINER_CREATION_DATE"), File.GetLastWriteTime(buildPath), PublisherUtils.GetUnityVersionOfBuild(buildPath)), container); SetupLabel("lblGameTitle", gameTitle, container); SetupLabel("lblBuildSize", string.Format(Localization.Tr("UPLOAD_CONTAINER_BUILD_SIZE"), PublisherUtils.FormatBytes(PublisherUtils.GetFolderSize(buildPath))), container); container.style.display = DisplayStyle.Flex; return; } SetupButton("btnOpenFolder", null, false, container); SetupButton("btnDelete", null, false, container); SetupButton("btnShare", null, false, container); SetupLabel("lblGameTitle", "-", container); SetupLabel("lblLastBuildInfo", "-", container); container.style.display = DisplayStyle.None; }