public static async ETTask SetContent(this UIBaseMessageWindow self, string key, bool play = true, bool clear = true) { if (string.IsNullOrEmpty(key)) { return; } I18NComponent.Instance.I18NTryGetText(key, out string text); var baseLen = self.showLen; self.allText += text; self.Text.SetText(self.allText); self.showLen = self.allText.Length; self.token = new ETCancellationToken(); self.isPlay = play; for (int i = baseLen + 1; i <= self.showLen && self.isPlay && self.speed > 0; i++) { self.Text.SetMaxVisibleCharacters(i); await TimerComponent.Instance.WaitAsync((long)(50 / self.speed), self.token); self.showLen = self.Text.GetCharacterCount(); } self.Text.SetMaxVisibleCharacters(int.MaxValue); self.isPlay = false; self.token = new ETCancellationToken(); if (GalGameEngineComponent.Instance.AutoPlay || !clear || self.speed <= 0) { if (self.speed <= 0) { await TimerComponent.Instance.WaitAsync(10); } else { await TimerComponent.Instance.WaitAsync((long)(self.waitTime / self.speed), self.token); } } if (!(GalGameEngineComponent.Instance.AutoPlay || !clear || self.speed <= 0)) { while (true) { KeyCode keycode = await GalGameEngineComponent.Instance.WaitInput; if (keycode == KeyCode.Mouse0) { break; } } } if (clear) { self.allText = ""; self.showLen = 0; } }
public static void OnRunningStateEnd(this UIBaseMessageWindow self) { self.speed = 0; self.OnCancel(); }
public static void OnCancel(this UIBaseMessageWindow self) { self.Text.SetMaxVisibleCharacters(int.MaxValue); self.isPlay = false; self.token?.Cancel(); }