public void OpenState(State state) { try { if (previewBackendProcess == null || previewBackendProcess.HasExited) { EditorUtility.DisplayDialog("Info", "Please, start preview viewer", "Ok"); Focus(); return; } var resourceFolder = Path.Combine(OutputFolder, "wwwroot"); Directory.CreateDirectory(resourceFolder); var tour = TourExporter.GenerateTour(resourceFolder, TourExporter.GenerateTourOptions.ForPreview()); if (tour == null) { EditorUtility.DisplayDialog("Error", "Can't create tour", "Ok"); return; } tour.firstStateId = state.GetExportedId(); BackgroundTaskInvoker.StartBackgroundTask(LivePreviewProcessHelper.SendCameraRotation(SceneView.lastActiveSceneView.rotation)); BackgroundTaskInvoker.StartBackgroundTask(LivePreviewProcessHelper.OpenTour(tour)); } finally { EditorUtility.ClearProgressBar(); } }
//#if DEBUG /// ------------------------------------------------------------------------------------ /// <summary> /// Displays the progress dialog and starts the background task (not on a background /// thread to make debugging easier). /// </summary> /// <param name="fDisplayUi">set to <c>true</c> to display the progress dialog, /// <c>false</c> to run without UI.</param> /// <param name="backgroundTask">The background task.</param> /// <param name="parameters">The paramters that will be passed to the background task /// </param> /// <returns>The return value from the background thread.</returns> /// <remarks>Use this method only temporary to debug the background task. It will /// run the task on the same thread as the progress dialog, thus preventing the progress /// dialog from work properly. However, it makes things easier to debug.</remarks> /// ------------------------------------------------------------------------------------ public object RunTask_DebuggingOnly(bool fDisplayUi, BackgroundTaskInvoker backgroundTask, params object[] parameters) { m_progressDialog.Shown -= new EventHandler(OnProgressDialogShown); m_backgroundTask = backgroundTask; m_parameters = parameters; if (fDisplayUi) { if (m_owner != null) { m_owner.Enabled = false; } m_progressDialog.Show(m_owner); } RunBackgroundTask(null); if (m_owner != null) { m_owner.Activate(); } if (m_Exception != null) { throw new WorkerThreadException("Background thread threw an exception", m_Exception); } return(m_RetValue); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Displays the progress dialog as a modal dialog and starts the background task. /// </summary> /// <param name="fDisplayUi">set to <c>true</c> to display the progress dialog, /// <c>false</c> to run without UI.</param> /// <param name="backgroundTask">The background task.</param> /// <param name="parameters">The paramters that will be passed to the background task</param> /// <returns>The return value from the background thread.</returns> /// ------------------------------------------------------------------------------------ public object RunTask(bool fDisplayUi, BackgroundTaskInvoker backgroundTask, params object[] parameters) { m_fDisplayUi = fDisplayUi; return(RunTask_DebuggingOnly(fDisplayUi, backgroundTask, parameters)); //m_backgroundTask = backgroundTask; //m_parameters = parameters; //if (!fDisplayUi) // m_progressDialog.WindowState = FormWindowState.Minimized; //if (m_owner == null) //{ // if (fDisplayUi) // m_progressDialog.ShowInTaskbar = true; // m_progressDialog.StatusMessage = string.Empty; //} //m_progressDialog.ShowDialog(m_owner); //if (m_Exception != null) //{ // throw new WorkerThreadException("Background thread threw an exception", // m_Exception); //} //System.Diagnostics.Debug.WriteLine("End of ProgressDialogWithTask.RunTask"); //return m_RetValue; }
public void Draw() { EditorGUILayout.BeginHorizontal(); GUILayout.Space(EditorGUI.indentLevel * 20); if (GUILayout.Button("Download last stable")) { BackgroundTaskInvoker.StartBackgroundTask(DownloadPack(ReleaseType.Stable)); } if (GUILayout.Button("pre-release")) { BackgroundTaskInvoker.StartBackgroundTask(DownloadPack(ReleaseType.PreRelease)); } EditorGUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Available", EditorStyles.boldLabel); if (GUILayout.Button("Refresh")) { UpdatePacksList(); } GUILayout.EndHorizontal(); if (buildPacks.Count == 0) { EditorGUILayout.LabelField("No versions", EditorStyles.label); } else { foreach (var pack in buildPacks) { pack.IsFolded = EditorGUILayout.Foldout(pack.IsFolded, pack.Version); if (pack.IsFolded) { RenderPack(pack); } } } if (buildPacks.Count > 0) { selectedbuildTagNum = EditorGUILayout.Popup("Selected version", selectedbuildTagNum, buildPackTags); CurrentPack = buildPacks[selectedbuildTagNum]; } else { EditorGUILayout.LabelField("Please, download some version", EditorStyles.label); CurrentPack = null; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// If <paramref name="progressDlg"/> is not <c>null</c> we run the background task /// with that progress dialog (without creating a separate thread). Otherwise we display /// a new progress dialog as a modal dialog and start the background task in a separate /// thread. /// </summary> /// <param name="progressDlg">The existing progress dialog, or <c>null</c>.</param> /// <param name="fDisplayUi">set to <c>true</c> to display the progress dialog, /// <c>false</c> to run without UI.</param> /// <param name="backgroundTask">The background task.</param> /// <param name="parameters">The paramters that will be passed to the background task</param> /// <returns>The return value from the background thread.</returns> /// ------------------------------------------------------------------------------------ public object RunTask(IAdvInd4 progressDlg, bool fDisplayUi, BackgroundTaskInvoker backgroundTask, params object[] parameters) { if (progressDlg != null) { int nMin; int nMax = 0; progressDlg.GetRange(out nMin, out nMax); progressDlg.Position = nMin; object ret = backgroundTask(progressDlg, parameters); progressDlg.SetRange(nMin, nMax); progressDlg.Position = nMax; return(ret); } return(RunTask(fDisplayUi, backgroundTask, parameters)); }
private void RenderPack(T pack) { EditorGUI.indentLevel++; switch (pack.Status) { case BuildPackStatus.NotLoaded: BackgroundTaskInvoker.StartBackgroundTask(GitHubApi.GetReleaseForRep(GithubRepo, pack.Id, p => { pack.PublishDate = p.PublishedAt; pack.Status = BuildPackStatus.Loaded; }, e => pack.Status = BuildPackStatus.LoadingError)); pack.Status = BuildPackStatus.Loading; break; case BuildPackStatus.Loading: EditorGUILayout.LabelField($"Downloading..."); break; case BuildPackStatus.Loaded: EditorGUILayout.LabelField($"Publish date: {pack.PublishDate:yyyy-MM-dd}"); if (GUI.Button(EditorGUI.IndentedRect(EditorGUILayout.GetControlRect()), "Remove")) { RemovePack(pack); UpdatePacksList(); } break; case BuildPackStatus.LoadingError: EditorGUILayout.LabelField($"Download error"); break; default: EditorGUILayout.LabelField($"Unexpected error"); break; } EditorGUI.indentLevel--; }
//#if DEBUG /// ------------------------------------------------------------------------------------ /// <summary> /// Displays the progress dialog and starts the background task (not on a background /// thread to make debugging easier). /// </summary> /// <param name="fDisplayUi">set to <c>true</c> to display the progress dialog, /// <c>false</c> to run without UI.</param> /// <param name="backgroundTask">The background task.</param> /// <param name="parameters">The paramters that will be passed to the background task /// </param> /// <returns>The return value from the background thread.</returns> /// <remarks>Use this method only temporary to debug the background task. It will /// run the task on the same thread as the progress dialog, thus preventing the progress /// dialog from work properly. However, it makes things easier to debug.</remarks> /// ------------------------------------------------------------------------------------ public object RunTask_DebuggingOnly(bool fDisplayUi, BackgroundTaskInvoker backgroundTask, params object[] parameters) { m_progressDialog.Shown -= new EventHandler(OnProgressDialogShown); m_backgroundTask = backgroundTask; m_parameters = parameters; if (fDisplayUi) { if (m_owner != null) m_owner.Enabled = false; m_progressDialog.Show(m_owner); } RunBackgroundTask(null); if (m_owner != null) m_owner.Activate(); if (m_Exception != null) { throw new WorkerThreadException("Background thread threw an exception", m_Exception); } return m_RetValue; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Displays the progress dialog as a modal dialog and starts the background task. /// </summary> /// <param name="fDisplayUi">set to <c>true</c> to display the progress dialog, /// <c>false</c> to run without UI.</param> /// <param name="backgroundTask">The background task.</param> /// <param name="parameters">The paramters that will be passed to the background task</param> /// <returns>The return value from the background thread.</returns> /// ------------------------------------------------------------------------------------ public object RunTask(bool fDisplayUi, BackgroundTaskInvoker backgroundTask, params object[] parameters) { m_fDisplayUi = fDisplayUi; return RunTask_DebuggingOnly(fDisplayUi, backgroundTask, parameters); //m_backgroundTask = backgroundTask; //m_parameters = parameters; //if (!fDisplayUi) // m_progressDialog.WindowState = FormWindowState.Minimized; //if (m_owner == null) //{ // if (fDisplayUi) // m_progressDialog.ShowInTaskbar = true; // m_progressDialog.StatusMessage = string.Empty; //} //m_progressDialog.ShowDialog(m_owner); //if (m_Exception != null) //{ // throw new WorkerThreadException("Background thread threw an exception", // m_Exception); //} //System.Diagnostics.Debug.WriteLine("End of ProgressDialogWithTask.RunTask"); //return m_RetValue; }
/// ------------------------------------------------------------------------------------ /// <summary> /// If <paramref name="progressDlg"/> is not <c>null</c> we run the background task /// with that progress dialog (without creating a separate thread). Otherwise we display /// a new progress dialog as a modal dialog and start the background task in a separate /// thread. /// </summary> /// <param name="progressDlg">The existing progress dialog, or <c>null</c>.</param> /// <param name="fDisplayUi">set to <c>true</c> to display the progress dialog, /// <c>false</c> to run without UI.</param> /// <param name="backgroundTask">The background task.</param> /// <param name="parameters">The paramters that will be passed to the background task</param> /// <returns>The return value from the background thread.</returns> /// ------------------------------------------------------------------------------------ public object RunTask(IAdvInd4 progressDlg, bool fDisplayUi, BackgroundTaskInvoker backgroundTask, params object[] parameters) { if (progressDlg != null) { int nMin; int nMax = 0; progressDlg.GetRange(out nMin, out nMax); progressDlg.Position = nMin; object ret = backgroundTask(progressDlg, parameters); progressDlg.SetRange(nMin, nMax); progressDlg.Position = nMax; return ret; } return RunTask(fDisplayUi, backgroundTask, parameters); }