コード例 #1
0
        static void ZipAndPublish(string title, string buildPath, Store <AppState> store)
        {
            store.Dispatch(new TitleChangeAction {
                title = title
            });

            if (!PublisherUtils.BuildIsValid(buildPath))
            {
                store.Dispatch(new OnErrorAction {
                    errorMsg = Localization.Tr("ERROR_BUILD_ABSENT")
                });
                return;
            }

            if (!Zip(store, buildPath))
            {
                return;
            }
            string GUIDPath = Path.Combine(buildPath, "GUID.txt");

            if (File.Exists(GUIDPath))
            {
                store.Dispatch(new UploadStartAction()
                {
                    buildGUID = File.ReadAllText(GUIDPath)
                });
                return;
            }
            Debug.LogWarningFormat("Missing GUID file for {0}, consider deleting the build and making a new one through the WebGL Publisher", buildPath);
            store.Dispatch(new UploadStartAction()
            {
                buildGUID = UndefinedGUID
            });
        }
コード例 #2
0
            void Start()
            {
                string buildPath = "C://Builds/MyAwesomeBuild";

                PublisherUtils.AddBuildDirectory(buildPath);
                PrintAllBuildsDirectories(); //will also display buildPath
            }
コード例 #3
0
        void SetupUploadTab()
        {
            List <string> existingBuildsPaths = PublisherUtils.GetAllBuildsDirectories();
            VisualElement buildsList          = rootVisualElement.Query <VisualElement>("buildsList");

            buildsList.contentContainer.Clear();

            VisualTreeAsset containerTemplate = UIElementsUtils.LoadUXML("BuildContainerTemplate");
            VisualElement   containerInstance;

            for (int i = 0; i < PublisherUtils.MaxDisplayedBuilds; i++)
            {
                containerInstance = containerTemplate.CloneTree().Q("buildContainer");
                SetupBuildContainer(containerInstance, existingBuildsPaths[i]);
                buildsList.contentContainer.Add(containerInstance);
            }

            SetupBuildButtonInUploadTab();

            ToolbarMenu helpMenu = rootVisualElement.Q <ToolbarMenu>("menuHelp");

            helpMenu.menu.AppendAction(Localization.Tr("UPLOAD_MENU_BUTTON_SETTINGS"), a => { OnOpenBuildSettingsClicked(); }, a => DropdownMenuAction.Status.Normal);
            helpMenu.menu.AppendAction(Localization.Tr("UPLOAD_MENU_BUTTON_LOCATEBUILD"), a => { OnLocateBuildClicked(); }, a => DropdownMenuAction.Status.Normal);
            helpMenu.menu.AppendAction(Localization.Tr("UPLOAD_MENU_BUTTON_TUTORIAL"), a => { OnOpenHelpClicked(); }, a => DropdownMenuAction.Status.Normal);
            helpMenu.menu.AppendAction(Localization.Tr("UPLOAD_MENU_BUTTON_AUTOPUBLISH"), a => { OnToggleAutoPublish(); }, a => { return(GetAutoPublishCheckboxStatus()); }, autoPublishSuccessfulBuilds.value);

            //hide the dropdown arrow
            IEnumerator <VisualElement> helpMenuChildrenEnumerator = helpMenu.Children().GetEnumerator();

            helpMenuChildrenEnumerator.MoveNext(); //get to the label (to ignore)
            helpMenuChildrenEnumerator.MoveNext(); //get to the dropdown arrow (to hide)
            helpMenuChildrenEnumerator.Current.visible = false;

            SetupLabel("lblTitle", "UPLOAD_TITLE", true);
        }
コード例 #4
0
            void Start()
            {
                PublisherState currentStep = PublisherUtils.GetCurrentPublisherState(PublisherWindow.FindInstance());

                Debug.Log(currentStep);
                switch (currentStep)
                {
                case PublisherState.Idle:
                    //your code here
                    break;

                case PublisherState.Login:
                    //your code here
                    break;

                case PublisherState.Zip:
                    //your code here
                    break;

                case PublisherState.Upload:
                    //your code here
                    break;

                case PublisherState.Process:
                    //your code here
                    break;

                default:
                    break;
                }
            }
コード例 #5
0
            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"
            }
コード例 #6
0
            void Start()
            {
                string buildPath = PublisherUtils.GetFirstValidBuildPath();

                if (string.IsNullOrEmpty(buildPath))
                {
                    Debug.LogError("There are no valid builds");
                    return;
                }
                Debug.Log("Your most recent valid build is located at: " + buildPath);
            }
コード例 #7
0
        /// <summary>
        /// Triggers the "Build Game" dialog
        /// </summary>
        /// <returns>True and the build path if everything goes well and the build is done, false and empty string otherwise.</returns>
        public static (bool, string) OpenBuildGameDialog(BuildTarget activeBuildTarget)
        {
            string path = string.Empty;

            try
            {
                string defaultOutputDirectory = PublisherUtils.GetFirstValidBuildPath();
                if (string.IsNullOrEmpty(defaultOutputDirectory) && CreateDefaultBuildsFolder)
                {
                    defaultOutputDirectory = DefaultBuildsFolderPath;
                    if (!Directory.Exists(defaultOutputDirectory))
                    {
                        Directory.CreateDirectory(defaultOutputDirectory);
                    }
                }

                path = EditorUtility.SaveFolderPanel(Localization.Tr("DIALOG_CHOOSE_BUILD_FOLDER"), defaultOutputDirectory, "");

                if (string.IsNullOrEmpty(path))
                {
                    return(false, string.Empty);
                }

                BuildPlayerOptions buildOptions = new BuildPlayerOptions();
                buildOptions.scenes           = EditorBuildSettingsScene.GetActiveSceneList(EditorBuildSettings.scenes);
                buildOptions.locationPathName = path;
                buildOptions.options          = BuildOptions.None;
                buildOptions.targetGroup      = BuildPipeline.GetBuildTargetGroup(activeBuildTarget);
                buildOptions.target           = activeBuildTarget;

                buildStartedFromTool = true;
                BuildReport report = BuildPipeline.BuildPlayer(buildOptions);
                buildStartedFromTool = false;

                AnalyticsHelper.BuildCompleted(report.summary.result, report.summary.totalTime);
                switch (report.summary.result)
                {
                case BuildResult.Cancelled:  //Debug.LogWarning("[Version and Build] Build cancelled! " + report.summary.totalTime);
                case BuildResult.Failed:     //Debug.LogError("[Version and Build] Build failed! " + report.summary.totalTime);
                    return(false, string.Empty);

                case BuildResult.Succeeded:   //Debug.Log("[Version and Build] Build succeeded! " + report.summary.totalTime);
                case BuildResult.Unknown:     //Debug.Log("[Version and Build] Unknown build result! " + report.summary.totalTime);
                    break;
                }
            }
            catch (BuildPlayerWindow.BuildMethodException /*e*/)
            {
                //Debug.LogError(e.Message);
                return(false, string.Empty);
            }
            return(true, path);
        }
コード例 #8
0
            void PrintAllBuildsDirectories()
            {
                List <string> existingBuildsPaths = PublisherUtils.GetAllBuildsDirectories();

                foreach (string path in existingBuildsPaths)
                {
                    if (path == string.Empty)
                    {
                        continue;
                    }
                    Debug.Log(path);
                }
            }
コード例 #9
0
        /// <summary>
        /// Called when the WebGL target platform is already selected or when the user switches to it through the Publisher
        /// </summary>
        internal void OnWebGLBuildTargetSet()
        {
            bool buildSettingsHaveNoActiveScenes = EditorBuildSettingsScene.GetActiveSceneList(EditorBuildSettings.scenes).Length == 0;

            if (buildSettingsHaveNoActiveScenes)
            {
                if (!PublisherUtils.AddCurrentSceneToBuildSettings())
                {
                    ShowSaveScenePopup();
                    return;
                }
            }
            PublisherBuildProcessor.OpenBuildGameDialog(BuildTarget.WebGL);
        }
コード例 #10
0
        void OnDeleteClicked(string buildPath, string gameTitle)
        {
            if (!Directory.Exists(buildPath))
            {
                Store.Dispatch(new OnErrorAction()
                {
                    errorMsg = Localization.Tr("ERROR_BUILD_NOT_FOUND")
                });
                return;
            }

            if (ShowDeleteBuildPopup(gameTitle))
            {
                AnalyticsHelper.ButtonClicked(string.Format("{0}_Delete_RemoveFromList", CurrentTab));
                PublisherUtils.RemoveBuildDirectory(buildPath);
                SetupUploadTab();
            }
        }
コード例 #11
0
        void OnPublishClicked(string gameBuildPath, string gameTitle)
        {
            AnalyticsHelper.ButtonClicked(string.Format("{0}_Publish", CurrentTab));
            if (!PublisherUtils.BuildIsValid(gameBuildPath))
            {
                Store.Dispatch(new OnErrorAction()
                {
                    errorMsg = Localization.Tr("ERROR_BUILD_CORRUPTED")
                });
                return;
            }

            this.gameTitle = gameTitle;
            FormatGameTitle();
            Store.Dispatch(new PublishStartAction()
            {
                title = gameTitle, buildPath = gameBuildPath
            });
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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;
        }
コード例 #14
0
        /// <summary>
        /// Called right after a build process ends
        /// </summary>
        /// <param name="report">A summary of the build process</param>
        public void OnPostprocessBuild(BuildReport report)
        {
            BuildSummary summary = report.summary;

            if (summary.platform != BuildTarget.WebGL)
            {
                return;
            }

            string buildOutputDir = summary.outputPath;
            string buildGUID      = summary.guid.ToString();

            PublisherUtils.AddBuildDirectory(buildOutputDir);

            PublisherWindow windowInstance = PublisherWindow.FindInstance();

            windowInstance?.Store.Dispatch(new BuildFinishAction
            {
                outputDir = buildOutputDir,
                buildGUID = buildGUID
            });

            WriteMetadataFilesAndFinalizeBuild(summary.outputPath, buildGUID);
        }
コード例 #15
0
        void OnLocateBuildClicked()
        {
            AnalyticsHelper.ButtonClicked(string.Format("{0}_LocateBuild", CurrentTab));

            string lastBuildPath = PublisherUtils.GetFirstValidBuildPath();

            if (string.IsNullOrEmpty(lastBuildPath) && PublisherBuildProcessor.CreateDefaultBuildsFolder)
            {
                lastBuildPath = PublisherBuildProcessor.DefaultBuildsFolderPath;
                if (!Directory.Exists(lastBuildPath))
                {
                    Directory.CreateDirectory(lastBuildPath);
                }
            }

            string buildPath = EditorUtility.OpenFolderPanel(Localization.Tr("DIALOG_CHOOSE_FOLDER"), lastBuildPath, string.Empty);

            if (string.IsNullOrEmpty(buildPath))
            {
                return;
            }
            if (!PublisherUtils.BuildIsValid(buildPath))
            {
                Store.Dispatch(new OnErrorAction()
                {
                    errorMsg = Localization.Tr("ERROR_BUILD_CORRUPTED")
                });
                return;
            }
            PublisherUtils.AddBuildDirectory(buildPath);
            if (CurrentTab != TabUpload)
            {
                return;
            }
            SetupUploadTab();
        }
コード例 #16
0
 void FormatGameTitle()
 {
     gameTitle = PublisherUtils.GetFilteredGameTitle(gameTitle);
 }
コード例 #17
0
            void Start()
            {
                string filteredTitle = PublisherUtils.GetFilteredGameTitle("A title with spaces"); //returns "A title with spaces"

                filteredTitle = PublisherUtils.GetFilteredGameTitle("     ");                      //returns "Untitled" (the value of PublisherUtils.DefaultGameName)
            }
コード例 #18
0
            void Start()
            {
                string latestBuildURL = PublisherUtils.GetUrlOfLastPublishedBuild(PublisherWindow.FindInstance());

                Debug.Log(latestBuildURL);
            }
コード例 #19
0
        void RebuildFrontend()
        {
            if (!string.IsNullOrEmpty(Store.state.errorMsg))
            {
                LoadTab(TabError);
                return;
            }

            if (openedForTheFirstTime)
            {
                LoadTab(TabIntroduction);
                return;
            }

            if (currentState != Store.state.step)
            {
                currentState = Store.state.step;
            }

            bool loggedOut = (currentState == PublisherState.Login);

            if (loggedOut)
            {
                LoadTab(TabNotLoggedIn);
                return;
            }

            if (!webGLIsInstalled)
            {
                UpdateWebGLInstalledFlag();
                LoadTab(TabInstallWebGL);
                return;
            }

            if (!PublisherUtils.ValidBuildExists())
            {
                LoadTab(TabNoBuild);
                return;
            }

            if (!string.IsNullOrEmpty(Store.state.url))
            {
                LoadTab(TabSuccess);
                return;
            }


            if (currentState == PublisherState.Upload)
            {
                LoadTab(TabUploading);
                return;
            }

            if (currentState == PublisherState.Process)
            {
                LoadTab(TabProcessing);
                return;
            }

            LoadTab(TabUpload);
        }