static void checkToken(string token) { CustomDialogUtils.showCustomDialog( child: new CustomLoadingDialog( message: "验证中" ) ); LoginApi.LoginByQr(token: token, "check").Then(success => { CustomDialogUtils.hiddenCustomDialog(); StoreProvider.store.dispatcher.dispatch( new MainNavigatorPushToQRScanLoginAction { token = token } ); CustomDialogUtils.showToast("验证成功", iconData: Icons.sentiment_satisfied); AnalyticsManager.AnalyticsQRScan(state: QRState.check); }).Catch(error => { CustomDialogUtils.hiddenCustomDialog(); CustomDialogUtils.showToast("验证失败", iconData: Icons.sentiment_dissatisfied); Promise.Delayed(new TimeSpan(0, 0, 1)) .Then(() => { PushToQRScan(); AnalyticsManager.AnalyticsQRScan(state: QRState.check, false); }); }); }
public static IEnumerable TouchGameDataFile(string path) { if (path == null) { throw new ArgumentNullException("path"); } var gameDataFile = default(FileStream); foreach (var attempt in Enumerable.Range(1, 5)) { try { gameDataFile = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read); break; } catch (IOException e) { if (Settings.Current.Verbose) { Debug.LogWarning("Attempt #" + attempt + " to touch " + path + " file has failed with IO error: " + Environment.NewLine + e); } if (gameDataFile != null) { gameDataFile.Dispose(); } } yield return(Promise.Delayed(TimeSpan.FromSeconds(1))); } yield return(gameDataFile); }
public override Widget build(BuildContext context) { if (this.duration != null) { Promise.Delayed((TimeSpan)this.duration) .Then(onResolved: CustomDialogUtils.hiddenCustomDialog); } return(new GestureDetector( onTap: () => { }, child: new Container( child: new Center( child: new Container( width: 132, height: 110, decoration: new BoxDecoration( Color.fromRGBO(0, 0, 0, 0.8f), borderRadius: BorderRadius.circular(4) ), child: new Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: new List <Widget> { this.widget ?? new CustomActivityIndicator(loadingColor: LoadingColor.white), _buildMessage(message: this.message) } ) ) ) ) )); }
public override void initState() { base.initState(); int currentTabIndex = StoreProvider.store.getState().tabBarState.currentTabIndex; if (currentTabIndex != 0) { return; } Promise.Delayed(TimeSpan.FromMilliseconds(1)).Then(() => { var rect = this.context.getContextRect(); var kingKongTypes = PreferencesManager.initKingKongType(); if (!kingKongTypes.Contains(item: KingKongType.dailyCollection)) { this._showDailyCollectionDialog(rect: rect, kingKongTypes: kingKongTypes); } else if (!kingKongTypes.Contains(item: KingKongType.leaderBoard)) { this._showLeaderBoardDialog(rect: rect, kingKongTypes: kingKongTypes); } else if (!kingKongTypes.Contains(item: KingKongType.blogger)) { this._showBloggerDialog(rect: rect); } }); }
public void Drop() { if (mStates == GameStates.Running && mCurrent != null) { for (var i = 0; i < 20; i++) { var next = mCurrent.Down(i + 1); if (!next.IsValidateInData(mData)) { mCurrent = mCurrent.Down(i); this.setState(() => { }); mStates = GameStates.Drop; Promise.Delayed(TimeSpan.FromMilliseconds(100)) .Then(() => { MixCurrentBlockIntoData(mixSound: AudioPlayer.Drop); setState(() => { }); }); break; } } } else if (mStates == GameStates.Paused || mStates == GameStates.None) { StartGame(); } }
Widget _buildTextField() { return(new CustomTextField( textFieldKey: this._inputFieldKey, hintText: "友好的评论是交流的起点…", controller: this._textController, autofocus: true, maxLines: 2, minLines: 1, showEmojiBoard: this.showEmojiBoard, isShowImageButton: false, onSubmitted: this._onSubmitted, onPressEmoji: () => { if (this.showEmojiBoard) { TextInputPlugin.TextInputShow(); Promise.Delayed(TimeSpan.FromMilliseconds(200)).Then( () => { if (this.mounted) { this.setState(() => this._showEmojiBoard = false); } }); } else { this.setState(() => this._showEmojiBoard = true); Promise.Delayed(TimeSpan.FromMilliseconds(100)).Then( onResolved: TextInputPlugin.TextInputHide ); } } )); }
void _contactFocusNodeListener() { if (this._contactFocusNode.hasFocus) { Promise.Delayed(TimeSpan.FromMilliseconds(300)).Then(() => { this._scrollListView(this._getPosition(this._contactFocusNodeKey)); }); } }
public void didPush() { StatusBarManager.hideStatusBar(true); Promise.Delayed(TimeSpan.FromMilliseconds(400)).Then(() => { var width = MediaQuery.of(this.context).size.width; var height = width * 9 / 16; var originY = (MediaQuery.of(this.context).size.height - height) / 2; AVPlayerPlugin.initVideoPlayer(this.widget.url, HttpManager.getCookie(), 0, originY, width, height, false, this.widget.needUpdate, this.widget.limitSeconds); }); }
void OnGUI() { this._selected = EditorGUILayout.Popup("test case", this._selected, this._optionStrings); if (this._selected == 3) { using (this._windowAdapter.getScope()) { if (GUI.Button(new Rect(20, 50, 100, 20), "Image 1")) { this.LoadImage( "http://a.hiphotos.baidu.com/image/h%3D300/sign=10b374237f0e0cf3bff748fb3a47f23d/adaf2edda3cc7cd90df1ede83401213fb80e9127.jpg"); } if (GUI.Button(new Rect(20, 150, 100, 20), "Image 2")) { this.LoadImage( "http://a.hiphotos.baidu.com/image/pic/item/cf1b9d16fdfaaf519b4aa960875494eef11f7a47.jpg"); } if (GUI.Button(new Rect(20, 250, 100, 20), "Image 3")) { this.LoadImage( "http://a.hiphotos.baidu.com/image/pic/item/2f738bd4b31c8701c1e721dd2a7f9e2f0708ffbc.jpg"); } } } this._windowAdapter.OnGUI(); if (Event.current.type == EventType.Repaint || Event.current.type == EventType.MouseDown) { this.createRenderTexture(); Window.instance = this._windowAdapter; if (Event.current.type == EventType.MouseDown) { Promise.Delayed(new TimeSpan(0, 0, 5)).Then(() => { Debug.Log("Promise.Delayed: 5s"); }); } this._options[this._selected](); Window.instance = null; Graphics.DrawTexture(new Rect(0, 0, this.position.width, this.position.height), this._renderTexture, _getGUITextureMat()); } }
public override Widget build(BuildContext context) { if (!this._isUp) { Promise.Delayed(duration: duration).Then(() => { if (this.mounted) { this._isUp = true; this.setState(() => {}); } }); } else { Promise.Delayed(duration: duration).Then(() => { if (this.mounted) { this._isUp = false; this.setState(() => {}); } }); } var triangleTop = this._isUp ? this.widget.triangleTop - 4 : this.widget.triangleTop; return(new Container( child: new Stack( children: new List <Widget> { new AnimatedPositioned( left: this.widget.triangleLeft, top: triangleTop, duration: duration, curve: curve, child: _buildTriangle() ), new AnimatedPositioned( left: this.widget.contentLeft, right: this.widget.contentRight, top: triangleTop + triangleSize.height, duration: duration, curve: curve, child: this._buildContent() ) } ) )); }
public override void initState() { base.initState(); int currentTabIndex = StoreProvider.store.getState().tabBarState.currentTabIndex; if (currentTabIndex != 0) { return; } Promise.Delayed(TimeSpan.FromMilliseconds(1)).Then(() => { var rect = this.context.getContextRect(); var kingKongTypes = PreferencesManager.initKingKongType(); if (!kingKongTypes.Contains(item: KingKongType.tinyGame)) { this._showTinyGameDialog(rect: rect); } }); }
private static IEnumerable RunCancellableProgress(string title, string message, float fromProgress, float toProgress, TimeSpan timeInterpolationWindow, Promise cancellation) { var startTime = DateTime.UtcNow; while (cancellation.IsCompleted == false) { var timeElapsed = DateTime.UtcNow - startTime; var timeElapsedRatio = (float)Math.Min(1.0f, Math.Max(0.0f, timeElapsed.TotalMilliseconds / timeInterpolationWindow.TotalMilliseconds)); var progress = fromProgress + (toProgress - fromProgress) * timeElapsedRatio; if (EditorUtility.DisplayCancelableProgressBar(title, message, progress) || EditorApplication.isCompiling) { yield return(true); } yield return(Promise.Delayed(TimeSpan.FromMilliseconds(100))); } yield return(false); }
protected void LoadUrl(string url) { if (!this.webView) { var editorAsm = typeof(UnityEditor.SceneView).Assembly; var engineAsm = typeof(UnityEngine.GUI).Assembly; var webViewRect = (Rect)engineAsm.GetType("UnityEngine.GUIClip", throwOnError: true).InvokeMember("Unclip", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public, null, null, new object[] { new Rect(0, 0, this.position.width, this.position.height) }); this.webView = CreateInstance(editorAsm.GetType("UnityEditor.WebView", throwOnError: true)); var hostView = this.GetFieldValue("m_Parent"); this.webView.Invoke("InitWebView", hostView, (int)(webViewRect.x + this.Padding.x), (int)(webViewRect.y + this.Padding.y), (int)(webViewRect.width - (this.Padding.width + this.Padding.x)), (int)(webViewRect.height - (this.Padding.height + this.Padding.y)), false); this.webView.SetPropertyValue("hideFlags", HideFlags.HideAndDontSave); } this.webView.Invoke("SetDelegateObject", this); this.webView.Invoke("LoadURL", url); if (Settings.Current.Verbose) { Debug.Log("WebView is loading '" + url + "'."); } Promise.Delayed(TimeSpan.FromSeconds(2)).ContinueWith(_ => this.Repaint()); }
void _handleModeChange() { switch (this.mode) { case RefreshStatus.refreshing: this._sizeController.setValue(1.0f); break; case RefreshStatus.completed: Promise.Delayed(TimeSpan.FromMilliseconds(this.widget.completeDuration)).Then(this._dismiss ); break; case RefreshStatus.failed: Promise.Delayed(TimeSpan.FromMilliseconds(this.widget.completeDuration)).Then(() => { this._dismiss(); this.widget.mode = RefreshStatus.idle; } ); break; } this.setState(() => { }); }
public IEnumerable PerformUpdateAsync() { var artifacts = new string[this.rows.Length]; try { // downloading for (var i = 0; i < this.rows.Length; i++) { var row = this.rows[i]; if (row.Disabled || row.Action == ACTION_SKIP) { continue; } var downloadProgress = this.GetProgressReportFor(row, i + 1, this.rows.Length); var downloadAsync = new Coroutine <string>(DownloadAsync(row, downloadProgress)); yield return(downloadAsync.IgnoreFault()); if (downloadAsync.HasErrors) { Debug.LogWarning(string.Format("Failed to download build version '{1}' of '{0}' product. Error: {2}", row.Name, row.SelectedVersion, downloadAsync.Error.Unwrap())); continue; } artifacts[i] = downloadAsync.GetResult(); if (Settings.Current.Verbose) { Debug.Log(string.Format("Downloading '{0}' to '{1}'.", row.Name, artifacts[i])); } } // cleanup for (var i = 0; i < this.rows.Length; i++) { var row = this.rows[i]; if (row.Disabled || row.Action == ACTION_SKIP || artifacts[i] == null) { continue; } if (row.Id == UpdateServerCli.PRODUCT_CHARON) { PreCharonDeploy(row.Location); } } // deploy for (var i = 0; i < this.rows.Length; i++) { var row = this.rows[i]; if (row.Disabled || row.Action == ACTION_SKIP || artifacts[i] == null) { continue; } if (Settings.Current.Verbose) { Debug.Log(string.Format("Deploying '{0}' from '{1}' to '{2}'.", row.Name, artifacts[i], row.Location)); } try { File.Delete(row.Location); File.Move(artifacts[i], row.Location); } catch (Exception moveError) { Debug.LogError(string.Format("Failed to move downloaded file to new location '{0}'.", row.Location)); Debug.LogError(moveError.Unwrap()); } var deployProgress = this.GetProgressReportFor(row, i + 1, this.rows.Length); if (row.Id == UpdateServerCli.PRODUCT_CHARON && artifacts[i] != null) { yield return(new Coroutine <object>(PostCharonDeployAsync(row.Location, deployProgress)).IgnoreFault()); } } // post deploy for (var i = 0; i < this.rows.Length; i++) { var row = this.rows[i]; if (row.Disabled || row.Action == ACTION_SKIP || artifacts[i] == null) { continue; } var assetLocation = FileAndPathUtils.MakeProjectRelative(row.Location); if (string.IsNullOrEmpty(assetLocation)) { continue; } AssetDatabase.ImportAsset(assetLocation, ImportAssetOptions.ForceUpdate); } this.updateStatus = Resources.UI_UNITYPLUGIN_PROGRESS_DONE; } finally { foreach (var tempFile in artifacts) { try { File.Delete(tempFile); } catch { /*ignore delete error*/ } } } this.Close(); // re-load window if not 'Close' button was pressed if (this.rows.All(r => r.Action == ACTION_SKIP) == false) { Promise.Delayed(TimeSpan.FromSeconds(1)).ContinueWith(_ => EditorWindow.GetWindow <UpdateWindow>(utility: true)); } }
protected void OnGUI() { GUILayout.Space(5); if (string.IsNullOrEmpty(this.ThanksMessage)) { GUI.enabled = this.reportCoroutine == null || this.reportCoroutine.IsCompleted; this.Name = EditorGUILayout.TextField(Resources.UI_UNITYPLUGIN_FEEDBACK_NAME_LABEL, this.Name); this.Email = EditorGUILayout.TextField(Resources.UI_UNITYPLUGIN_FEEDBACK_EMAIL_LABEL, this.Email); this.Type = (IssueType)EditorGUILayout.EnumPopup(Resources.UI_UNITYPLUGIN_FEEDBACK_TYPE_LABEL, this.Type); this.Description = EditorGUILayout.TextArea(this.Description, GUILayout.Height(120)); GUILayout.Space(5); if (this.Attachments == null) { this.Attachments = new HashSet <string>(); } if (this.attachmentsToAdd == null) { this.attachmentsToAdd = new HashSet <string>(); } if (this.attachmentsToRemove == null) { this.attachmentsToRemove = new HashSet <string>(); } foreach (var attachmentFile in this.Attachments) { var fileInfo = new FileInfo(attachmentFile); if (GUILayout.Toggle(true, string.Format(Resources.UI_UNITYPLUGIN_FEEDBACK_ATTACH_FILE_CHECKBOX, fileInfo.Name, fileInfo.Length / 1024.0 / 1024.0)) == false) { this.attachmentsToRemove.Add(attachmentFile); } } GUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button(Resources.UI_UNITYPLUGIN_FEEDBACK_ATTACH_FILE_BUTTON, EditorStyles.toolbarButton, GUILayout.Width(70), GUILayout.Height(18))) { var file = EditorUtility.OpenFilePanel(Resources.UI_UNITYPLUGIN_SELECT_FILE_TO_ATTACH_TITLE, "", ""); if (!string.IsNullOrEmpty(file) && File.Exists(file)) { this.attachmentsToAdd.Add(Path.GetFullPath(file)); } } GUILayout.Space(5); GUILayout.EndHorizontal(); GUILayout.Space(5); if (!string.IsNullOrEmpty(this.LastError)) { GUILayout.Box(this.LastError); } GUILayout.Space(18); GUILayout.BeginHorizontal(); EditorGUILayout.Space(); var reporter = string.Empty; if (string.IsNullOrEmpty(this.Email) == false && string.IsNullOrEmpty(this.Name) == false) { reporter = "<" + this.Name + ">" + this.Email; } else if (string.IsNullOrEmpty(this.Email) == false) { reporter = this.Email; } else { reporter = this.Name; } GUI.enabled = !string.IsNullOrEmpty(reporter) && !string.IsNullOrEmpty(this.Description) && (this.reportCoroutine == null || this.reportCoroutine.IsCompleted); if (GUILayout.Button(Resources.UI_UNITYPLUGIN_FEEDBACK_SEND_BUTTON, GUILayout.Width(80))) { this.reportCoroutine = this.ReportIssue(reporter, this.Description, this.Type, this.Attachments).ContinueWith(p => { if (p.HasErrors) { this.LastError = p.Error.Unwrap().Message; } else { this.LastError = null; this.Description = null; this.Type = IssueType.Bug; this.Attachments = null; this.attachmentsToAdd = null; this.attachmentsToRemove = null; this.ThanksMessage = Resources.UI_UNITYPLUGIN_FEEDBACK_THANKS_MESSAGE; Promise.Delayed(TimeSpan.FromSeconds(3)).ContinueWith(_ => this.Close()); } this.Repaint(); }); } GUI.enabled = true; GUILayout.EndHorizontal(); } else { GUILayout.Box(this.ThanksMessage, new GUIStyle { fontSize = 24, alignment = TextAnchor.MiddleCenter }); } GUILayoutUtility.GetRect(1, 1, 1, 1); if (Event.current.type == EventType.repaint && GUILayoutUtility.GetLastRect().y > 0) { var newRect = GUILayoutUtility.GetLastRect(); this.position = new Rect(this.position.position, new Vector2(this.position.width, newRect.y + 7)); this.minSize = this.maxSize = this.position.size; } }
VideoPlayer _videoPlayer(string url) { var player = VideoPlayerManager.instance.getPlayer(); var audioSource = VideoPlayerManager.instance.getAudioSource(); player.url = url; player.renderMode = VideoRenderMode.RenderTexture; player.source = VideoSource.Url; player.audioOutputMode = VideoAudioOutputMode.AudioSource; player.SetTargetAudioSource(0, audioSource); player.playOnAwake = false; player.IsAudioTrackEnabled(0); player.targetTexture = this._texture; player.isLooping = false; player.sendFrameReadyEvents = true; player.aspectRatio = VideoAspectRatio.Stretch; player.prepareCompleted += this.prepareCompleted; player.frameReady += (source, frameIndex) => { using (WindowProvider.of(this.widget.context).getScope()) { _pauseAudioSession(); Texture.textureFrameAvailable(); if (this._relative * source.frameCount < frameIndex || frameIndex == 0) { this._isLoaded = true; if (!this._isHiddenBar && !this._isReadyHiddenBar) { this._isReadyHiddenBar = true; this._hiddenBar(); } } this._relative = (float)frameIndex / source.frameCount; this._isFailure = false; if (this._playState == PlayState.play) { this._player.Play(); } if (frameIndex == 0) { Promise.Delayed(TimeSpan.FromMilliseconds(200)).Then(() => { if (this.mounted) { this.setState(() => {}); } }); } else { this.setState(() => { }); } } }; player.loopPointReached += _player => { using (WindowProvider.of(this.widget.context).getScope()) { this._relative = 0.0f; this._playState = PlayState.stop; _player.Stop(); _player.frame = 0; this.cancelTimer(); this._isHiddenBar = false; this._isReadyHiddenBar = false; this.setState(() => { }); } }; player.errorReceived += this._errorReceived; player.Prepare(); player.Pause(); return(player); }
public IEnumerable PerformUpdateAsync() { var deploymentActions = new List <DeploymentAction>(); try { // downloading for (var i = 0; i < this.rows.Length; i++) { var row = this.rows[i]; if (row.Disabled || row.Action == DeploymentAction.ACTION_SKIP) { continue; } var progressCallback = this.GetProgressReportFor(row, i + 1, this.rows.Length); var downloadVersion = default(SemanticVersion); if (row.Action == DeploymentAction.ACTION_DOWNLOAD || row.Action == DeploymentAction.ACTION_UPDATE) { downloadVersion = row.SelectedVersion; } else if (row.Action == DeploymentAction.ACTION_REPAIR) { downloadVersion = row.CurrentVersion.GetResult(); } if (row.Id == ProductInformation.PRODUCT_CHARON) { deploymentActions.Add(new CharonDeploymentAction(downloadVersion, progressCallback)); } else { deploymentActions.Add(new LibraryDeploymentAction(row.Id, downloadVersion, row.Location, progressCallback)); } } if (deploymentActions.Count == 0) { yield break; } // call prepare yield return(Promise.WhenAll(deploymentActions.ConvertAll(a => a.Prepare()).ToArray()).IgnoreFault()); // call deploy yield return(Promise.WhenAll(deploymentActions.ConvertAll(a => a.Complete()).ToArray()).IgnoreFault()); foreach (var forceReImportPath in deploymentActions.SelectMany(a => a.ChangedAssets)) { AssetDatabase.ImportAsset(forceReImportPath, ImportAssetOptions.ForceUpdate); } this.updateStatus = Resources.UI_UNITYPLUGIN_PROGRESS_DONE; } finally { foreach (var deploymentAction in deploymentActions) { deploymentAction.CleanUp(); } } this.Close(); // re-load window if not 'Close' button was pressed if (this.rows.All(r => r.Action == DeploymentAction.ACTION_SKIP) == false) { Promise.Delayed(TimeSpan.FromSeconds(1)).ContinueWith(_ => EditorWindow.GetWindow <UpdateWindow>(utility: true)); } }
private static IEnumerable LoadEditor(string gameDataPath, string reference, Promise waitTask) { // un-select gamedata file in Project window if (Selection.activeObject != null && AssetDatabase.GetAssetPath(Selection.activeObject) == gameDataPath) { Selection.activeObject = null; } if (waitTask != null) { yield return(waitTask.IgnoreFault()); } var title = Path.GetFileName(gameDataPath); if (EditorUtility.DisplayCancelableProgressBar(title, Resources.UI_UNITYPLUGIN_WINDOW_EDITOR_CHECKING_RUNTIME, 0.05f)) { throw new InvalidOperationException("Interrupted by user."); } var checkRequirements = CharonCli.CheckRequirementsAsync(); yield return(checkRequirements); switch (checkRequirements.GetResult()) { case RequirementsCheckResult.MissingRuntime: yield return(UpdateRuntimeWindow.ShowAsync()); break; case RequirementsCheckResult.WrongVersion: case RequirementsCheckResult.MissingExecutable: yield return(CharonCli.DownloadCharon(ProgressUtils.ShowCancellableProgressBar(Resources.UI_UNITYPLUGIN_MENU_CHECK_UPDATES, 0.05f, 0.50f))); break; case RequirementsCheckResult.Ok: break; default: throw new InvalidOperationException("Unknown requirements check result."); } var port = Settings.Current.EditorPort; var gameDataEditorUrl = "http://localhost:" + port + "/"; var lockFilePath = CharonCli.GetDefaultLockFilePath(); CharonCli.FindAndEndGracefully(lockFilePath); if (Settings.Current.Verbose) { Debug.Log("Starting gamedata editor at " + gameDataEditorUrl + "..."); } if (EditorUtility.DisplayCancelableProgressBar(title, Resources.UI_UNITYPLUGIN_WINDOW_EDITOR_LAUNCHING_EXECUTABLE, 0.50f)) { throw new InvalidOperationException("Interrupted by user."); } if (EditorApplication.isCompiling) { throw new InvalidOperationException("Interrupted by Unity's script compilation. Retry after Unity is finished script compilation."); } var charonRunTask = CharonCli.Listen(gameDataPath, lockFilePath, port, shadowCopy: true, progressCallback: ProgressUtils.ShowCancellableProgressBar(title, 0.50f, 0.60f)); if (Settings.Current.Verbose) { Debug.Log("Launching gamedata editor process."); } // wait untill server process start var timeoutPromise = Promise.Delayed(TimeSpan.FromSeconds(10)); var startPromise = (Promise)charonRunTask.IgnoreFault(); var startCompletePromise = Promise.WhenAny(timeoutPromise, startPromise); var cancelPromise = new Coroutine <bool>(RunCancellableProgress(title, Resources.UI_UNITYPLUGIN_WINDOW_EDITOR_LAUNCHING_EXECUTABLE, 0.65f, 0.80f, TimeSpan.FromSeconds(5), startCompletePromise)); yield return(Promise.WhenAny(timeoutPromise, startPromise, cancelPromise)); if (timeoutPromise.IsCompleted) { EditorUtility.ClearProgressBar(); Debug.LogWarning(Resources.UI_UNITYPLUGIN_WINDOW_FAILED_TO_START_EDITOR_TIMEOUT); yield break; } else if (cancelPromise.IsCompleted) { EditorUtility.ClearProgressBar(); if (EditorApplication.isCompiling) { throw new InvalidOperationException("Interrupted by Unity's script compilation. Retry after Unity is finished script compilation."); } else { throw new InvalidOperationException("Interrupted by user."); } } else if (charonRunTask.HasErrors) { throw new InvalidOperationException("Failed to start editor.", charonRunTask.Error.Unwrap()); } if (EditorUtility.DisplayCancelableProgressBar(title, Resources.UI_UNITYPLUGIN_WINDOW_EDITOR_LAUNCHING_EXECUTABLE, 0.80f)) { throw new InvalidOperationException("Interrupted by user."); } if (EditorApplication.isCompiling) { throw new InvalidOperationException("Interrupted by Unity's script compilation. Retry after Unity is finished script compilation."); } // wait untill server start to respond var downloadStream = new MemoryStream(); timeoutPromise = Promise.Delayed(TimeSpan.FromSeconds(10)); startPromise = HttpUtils.DownloadTo(downloadStream, new Uri(gameDataEditorUrl), timeout: TimeSpan.FromSeconds(1)); startCompletePromise = new Promise(); cancelPromise = new Coroutine <bool>(RunCancellableProgress(title, Resources.UI_UNITYPLUGIN_WINDOW_EDITOR_LAUNCHING_EXECUTABLE, 0.80f, 0.90f, TimeSpan.FromSeconds(5), startCompletePromise)); while (!timeoutPromise.IsCompleted) { yield return(startPromise.IgnoreFault()); if (startPromise.HasErrors == false && downloadStream.Length > 0) { break; } if (EditorUtility.DisplayCancelableProgressBar(title, Resources.UI_UNITYPLUGIN_WINDOW_EDITOR_LAUNCHING_EXECUTABLE, 0.93f)) { throw new InvalidOperationException("Interrupted by user."); } if (EditorApplication.isCompiling) { throw new InvalidOperationException("Interrupted by Unity's script compilation. Retry after Unity is finished script compilation."); } downloadStream.SetLength(0); startPromise = HttpUtils.DownloadTo(downloadStream, new Uri(gameDataEditorUrl), timeout: TimeSpan.FromSeconds(1)); } if (timeoutPromise.IsCompleted && (!startPromise.IsCompleted || startPromise.HasErrors)) { EditorUtility.ClearProgressBar(); startCompletePromise.TrySetCompleted(); Debug.LogWarning(Resources.UI_UNITYPLUGIN_WINDOW_FAILED_TO_START_EDITOR_TIMEOUT); yield break; } startCompletePromise.TrySetCompleted(); if (EditorUtility.DisplayCancelableProgressBar(title, Resources.UI_UNITYPLUGIN_WINDOW_EDITOR_OPENING_BROWSER, 0.95f)) { throw new InvalidOperationException("Interrupted by user."); } if (EditorApplication.isCompiling) { throw new InvalidOperationException("Interrupted by Unity's script compilation. Retry after Unity is finished script compilation."); } var nearPanels = typeof(SceneView); var editorWindow = GetWindow <GameDataEditorWindow>(nearPanels); editorWindow.titleContent = new GUIContent(title); var browserType = (BrowserType)Settings.Current.Browser; if (browserType == BrowserType.UnityEmbedded && !IsWebViewAvailable) { browserType = BrowserType.SystemDefault; } switch (browserType) { case BrowserType.UnityEmbedded: editorWindow.LoadUrl(gameDataEditorUrl + reference); editorWindow.SetWebViewVisibility(true); editorWindow.Repaint(); editorWindow.Focus(); break; case BrowserType.Custom: if (string.IsNullOrEmpty(Settings.Current.BrowserPath)) { goto case BrowserType.SystemDefault; } Process.Start(Settings.Current.BrowserPath, gameDataEditorUrl + reference); editorWindow.isOffsiteBrowserLaunched = true; break; case BrowserType.SystemDefault: EditorUtility.OpenWithDefaultApp(gameDataEditorUrl + reference); editorWindow.isOffsiteBrowserLaunched = true; break; } }
private static IEnumerable RunAsync(RunOptions options) { yield return(null); var isDotNetInstalled = false; if (RuntimeInformation.IsWindows) { isDotNetInstalled = DotNetRuntimeInformation.GetVersion() != null; } if (options.RequireDotNetRuntime && isDotNetInstalled == false) { if (string.IsNullOrEmpty(MonoRuntimeInformation.MonoPath)) { throw new InvalidOperationException("No .NET runtime found on machine."); } options.StartInfo.Arguments = RunOptions.ConcatenateArguments(options.StartInfo.FileName) + " " + options.StartInfo.Arguments; options.StartInfo.FileName = MonoRuntimeInformation.MonoPath; } if (options.CaptureStandardError) { options.StartInfo.RedirectStandardError = true; } if (options.CaptureStandardOutput) { options.StartInfo.RedirectStandardOutput = true; } if (Settings.Current.Verbose) { UnityEngine.Debug.Log(string.Format("Starting process '{0}' at '{1}' with arguments '{2}' and environment variables '{3}'.", options.StartInfo.FileName, options.StartInfo.WorkingDirectory, options.StartInfo.Arguments, ConcatenateDictionaryValues(options.StartInfo.EnvironmentVariables))); } var processStarted = DateTime.UtcNow; var timeout = options.ExecutionTimeout; if (timeout <= TimeSpan.Zero) { timeout = TimeSpan.MaxValue; } var process = Process.Start(options.StartInfo); if (process == null) { throw new InvalidOperationException("Unknown process start error."); } var result = new RunResult(options, process); if (options.WaitForExit == false) { //if (Settings.Current.Verbose) // UnityEngine.Debug.Log(string.Format("Yielding started process '{0}' at '{1}' with arguments '{2}'.", options.StartInfo.FileName, options.StartInfo.WorkingDirectory, options.StartInfo.Arguments)); yield return(result); yield break; } var hasExited = false; while (hasExited == false) { if (DateTime.UtcNow - processStarted > timeout) { throw new TimeoutException(); } try { process.Refresh(); hasExited = process.HasExited; } catch (InvalidOperationException) { // ignored } catch (System.ComponentModel.Win32Exception) { // ignored } yield return(Promise.Delayed(TimeSpan.FromMilliseconds(50))); } processStarted = DateTime.UtcNow; timeout = options.TerminationTimeout; if (timeout <= TimeSpan.Zero) { timeout = TimeSpan.MaxValue; } while (result.HasPendingData) { if (DateTime.UtcNow - processStarted > timeout) { throw new TimeoutException(); } yield return(Promise.Delayed(TimeSpan.FromMilliseconds(50))); } result.ExitCode = process.ExitCode; if (Settings.Current.Verbose) { UnityEngine.Debug.Log(string.Format("Process #{1} '{0}' has exited with code {2}.", options.StartInfo.FileName, result.ProcessId, result.ExitCode)); } yield return(result); }
public override Widget build(BuildContext context) { return(new Material( color: mColor, elevation: 2, shape: new CircleBorder(), child: new GestureDetector( behavior: HitTestBehavior.opaque, onTapDown: details => { this.setState(() => { mColor = widget.Color.withOpacity(0.5f); }); if (mTimer != null) { return; } mTapEnd = false; widget.OnTap(); if (!widget.EnableLongPress) { return; } Promise.Delayed(TimeSpan.FromMilliseconds(300)) .Then(() => { if (!mTapEnd) { mTimer = Window.instance.periodic(TimeSpan.FromMilliseconds(60), () => { if (mTapEnd) { mTimer?.cancel(); mTimer = null; } else { widget.OnTap(); } }); } }); }, onTapCancel: () => { mTimer?.cancel(); mTimer = null; mTapEnd = true; this.setState(() => { mColor = widget.Color; }); }, onTapUp: details => { mTimer?.cancel(); mTimer = null; mTapEnd = true; this.setState(() => { mColor = widget.Color; }); }, child: SizedBox.fromSize( size: widget.Size ) ) )); }