void OnSelectImageClicked()
        {
            long ThumbnailLimitBytes = 5 * 1024 * 1024; // 5 MBs

            string path = EditorUtility.OpenFilePanel("Select thumbnail", "", "jpg,jpeg,png");

            if (path.Length == 0)
            {
                return;
            }

            FileInfo fileInfo = new FileInfo(path);

            if (fileInfo.Length > ThumbnailLimitBytes)
            {
                //[TODO] Just show the error without using the middleware?
                store.Dispatch(new OnErrorAction()
                {
                    errorMsg = $"Max. file size {SharePackageUtils.FormatBytes((ulong)ThumbnailLimitBytes)}"
                });
                return;
            }
            SharePackageUtils.SetThumbnailPath(path);
            SetupImage("imgThumbnail", path);
        }
Ejemplo n.º 2
0
        private static bool Zip(Store <AppState> store, string buildOutputDir)
        {
            var projectDir = Directory.GetParent(Application.dataPath).FullName;
            var destPath   = Path.Combine(projectDir, zipName);

            File.Delete(destPath);

            CopyThumbnail(store);

            ZipFile.CreateFromDirectory(buildOutputDir, destPath);
            FileInfo fileInfo = new FileInfo(destPath);

            if (fileInfo.Length > ZipFileLimitBytes)
            {
                store.Dispatch(new OnErrorAction {
                    errorMsg = $"Max. allowed WebGL game .zip size is {SharePackageUtils.FormatBytes(ZipFileLimitBytes)}."
                });
                return(false);
            }
            store.Dispatch(new ZipPathChangeAction {
                zipPath = destPath
            });
            return(true);
        }