Ejemplo n.º 1
0
        public void OnPreprocessBuild(BuildReport report)
        {
            if (report.summary.platform != BuildTarget.WebGL)
            {
                return;
            }
            AnalyticsHelper.BuildStarted(buildStartedFromTool);

            if (buildStartedFromTool)
            {
                return;
            }
            //then we need to wait until the build process finishes, in order to get the proper BuildReport
            EditorCoroutineUtility.StartCoroutineOwnerless(WaitUntilBuildFinishes(report));
        }
        void OnShareClicked(string gameBuildPath)
        {
            AnalyticsHelper.ButtonClicked(string.Format("{0}_Publish", currentTab));
            if (!ShareUtils.BuildIsValid(gameBuildPath))
            {
                Store.Dispatch(new OnErrorAction()
                {
                    errorMsg = "This build is corrupted or missing, please delete it and choose another one to publish"
                });
                return;
            }

            Store.Dispatch(new ShareStartAction()
            {
                title = gameTitle, buildPath = gameBuildPath
            });
        }
        private static void CheckProgress(Store <AppState> store, string key)
        {
            var token = UnityConnectSession.instance.GetAccessToken();

            if (token.Length == 0)
            {
                CheckLoginStatus(store);
                return;
            }

            key = key ?? store.state.key;
            string baseUrl = GetAPIBaseUrl();

            var uploadRequest = UnityWebRequest.Get($"{baseUrl + queryProgressEndpoint}?key={key}");

            uploadRequest.SetRequestHeader("Authorization", $"Bearer {token}");
            uploadRequest.SetRequestHeader("X-Requested-With", "XMLHTTPREQUEST");
            var op = uploadRequest.SendWebRequest();

            op.completed += operation =>
            {
#if UNITY_2020
                if ((uploadRequest.result == UnityWebRequest.Result.ConnectionError) ||
                    (uploadRequest.result == UnityWebRequest.Result.ProtocolError))
#else
                if (uploadRequest.isNetworkError || uploadRequest.isHttpError)
#endif
                {
                    AnalyticsHelper.UploadCompleted(UploadResult.Failed);
                    Debug.LogError(uploadRequest.error);
                    StopUploadAction();
                    return;
                }
                var response = JsonUtility.FromJson <GetProgressResponse>(op.webRequest.downloadHandler.text);

                store.Dispatch(new QueryProgressResponseAction {
                    response = response
                });
                if (response.progress == 100 || !string.IsNullOrEmpty(response.error))
                {
                    SaveProjectID(response.projectId);
                    return;
                }
                EditorCoroutineUtility.StartCoroutineOwnerless(RefreshProcessingProgress(1.5f, store));
            };
        }
Ejemplo n.º 4
0
        void OnDeleteClicked(string buildPath, string gameTitle)
        {
            if (!Directory.Exists(buildPath))
            {
                Store.Dispatch(new OnErrorAction()
                {
                    errorMsg = "Build folder not found"
                });
                return;
            }

            if (ShowDeleteBuildPopup(gameTitle))
            {
                AnalyticsHelper.ButtonClicked(string.Format("{0}_Delete_RemoveFromList", currentTab));
                ShareUtils.RemoveBuildDirectory(buildPath);
                SetupUploadTab();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Triggers the "Build Game" dialog
        /// </summary>
        /// <returns>true if everything goes well and the build is done, false otherwise</returns>
        public static bool OpenBuildGameDialog(BuildTarget activeBuildTarget)
        {
            try
            {
                string path = EditorUtility.SaveFolderPanel("Choose Location of Built Application", "Builds", "");
                if (string.IsNullOrEmpty(path))
                {
                    return(false);
                }

                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;                                  //Debug.Log("building " + buildOptions.locationPathName);
                BuildReport report = BuildPipeline.BuildPlayer(buildOptions); //Debug.LogError("OnPostprocessBuild custom");
                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);

                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);
            }
            return(true);
        }
Ejemplo n.º 6
0
        void OnLocateBuildClicked()
        {
            AnalyticsHelper.ButtonClicked(string.Format("{0}_LocateBuild", currentTab));

            string lastBuildPath = ShareUtils.GetFirstValidBuildPath();

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

            string buildPath = EditorUtility.OpenFolderPanel("Choose folder", lastBuildPath, string.Empty);

            if (string.IsNullOrEmpty(buildPath))
            {
                return;
            }
            if (!ShareUtils.BuildIsValid(buildPath))
            {
                Store.Dispatch(new OnErrorAction()
                {
                    errorMsg = "This build is corrupted or missing, please delete it and choose another one to share"
                });
                return;
            }
            ShareUtils.AddBuildDirectory(buildPath);
            if (currentTab != TAB_UPLOAD)
            {
                return;
            }
            SetupUploadTab();
        }
 void OnOpenBuildFolderClicked(string buildPath)
 {
     AnalyticsHelper.ButtonClicked(string.Format("{0}_OpenBuildFolder", currentTab));
     EditorUtility.RevealInFinder(buildPath);
 }
 void OnCancelUploadClicked()
 {
     AnalyticsHelper.ButtonClicked(string.Format("{0}_CancelUpload", currentTab));
     AnalyticsHelper.UploadCompleted(UploadResult.Cancelled);
     Store.Dispatch(new StopUploadAction());
 }
 void OnFinishClicked()
 {
     AnalyticsHelper.ButtonClicked(string.Format("{0}_Finish", currentTab));
     Store.Dispatch(new DestroyAction());
 }
 void OnOpenBuildSettingsClicked()
 {
     AnalyticsHelper.ButtonClicked(string.Format("{0}_OpenBuildSettings", currentTab));
     BuildPlayerWindow.ShowBuildPlayerWindow();
 }
 void OnOpenHelpClicked()
 {
     AnalyticsHelper.ButtonClicked(string.Format("{0}_OpenHelp", currentTab));
     Application.OpenURL("https://learn.unity.com/tutorial/fps-mod-share-your-game-on-the-web?projectId=5d9c91a4edbc2a03209169ab#5db306f5edbc2a001f7a307d");
 }
 void OnSignInClicked()
 {
     AnalyticsHelper.ButtonClicked(string.Format("{0}_SignIn", currentTab));
     UnityConnectSession.instance.ShowLogin();
 }
Ejemplo n.º 13
0
 void OnToggleAutoPublish()
 {
     AnalyticsHelper.ButtonClicked(string.Format("{0}_ToggleAutoPublish", currentTab));
     autoPublishSuccessfulBuilds.SetValue(!autoPublishSuccessfulBuilds);
     SetupBuildButtonInUploadTab();
 }