public void SpawnText(string text, float duration) { if (!textSpawner) { return; } Vector3 position = new Vector3(0, 10, 0); float initialDuration = textSpawner.GetField <float, FlyingTextSpawner>("_duration"); textSpawner.SetField("_duration", duration); textSpawner.SpawnText(position, worldRotation, inverseWorldRotation, text); textSpawner.SetField("_duration", initialDuration); }
private void LoadTextSpawners() { var installer = Resources.FindObjectsOfTypeAll <EffectPoolsManualInstaller>().LastOrDefault(); if (installer != null) { var containers = Resources.FindObjectsOfTypeAll <MonoInstallerBase>(); foreach (MonoInstallerBase a in containers) { try { if (textSpawner == null) { //Get Main Text Spawner var container = a.GetProperty <DiContainer, MonoInstallerBase>("Container"); if (container == null) { continue; } if (!container.HasBinding(typeof(FlyingTextEffect.Pool))) { continue; } textSpawner = container.InstantiateComponentOnNewGameObject <FlyingTextSpawner>("GameSaber GameText Spawner"); textSpawner.SetField("_targetYPos", 3.0f); //Get Comment Text Spawners var commentSpawnerL = container.InstantiateComponentOnNewGameObject <FlyingTextSpawner>("GameSaber CommentSpawnerL"); commentSpawnerL.gameObject.transform.localPosition += new Vector3(-2f, 0, 0); commentSpawnerL.SetField("_shake", true); commentSpawnerL.SetField("_xSpread", 1.5f); commentSpawnerL.SetField("_targetZPos", 6.8f); commentSpawnerL.SetField("_targetYPos", 3.0f); var commentSpawnerR = container.InstantiateComponentOnNewGameObject <FlyingTextSpawner>("GameSaber CommentSpawnerR"); commentSpawnerR.gameObject.transform.localPosition += new Vector3(2f, 0, 0); commentSpawnerR.SetField("_shake", true); commentSpawnerR.SetField("_xSpread", 1.5f); commentSpawnerR.SetField("_targetZPos", 6.8f); commentSpawnerR.SetField("_targetYPos", 3.0f); commentTextSpawners.Add(commentSpawnerL); commentTextSpawners.Add(commentSpawnerR); } } catch (Exception ex) { Logger.log.Debug($"Exception creating textSpawners {ex}"); } } } }
public IEnumerator Start() { // The goal now is to find the clip this scene will be playing. // For this, we find the single root gameObject (which is the gameObject // to which we are attached), // then we get its GameSongController to find the audio clip, // and its FlyingTextSpawner to display the lyrics. if (Settings.VerboseLogging) { Debug.Log("[Beat Singer] Attached to scene."); Debug.Log($"[Beat Singer] Lyrics are enabled: {Settings.DisplayLyrics}."); } if (!Settings.DisplayLyrics) { yield break; } //Create a FlyingTextSpawner (Based on Custom Miss Text) var installer = Resources.FindObjectsOfTypeAll <EffectPoolsInstaller>().FirstOrDefault(); if (installer != null) { var containers = Resources.FindObjectsOfTypeAll <MonoInstallerBase>(); foreach (MonoInstallerBase a in containers) { if (textSpawner == null) { try { var container = a.GetProperty <DiContainer>("Container"); textSpawner = container.InstantiateComponentOnNewGameObject <FlyingTextSpawner>("CustomMissTextSpawner"); } catch (Exception ex) { Debug.Log("Exception creating TextSpawner"); } } } // .First().GetProperty<DiContainer>("Container"); // textSpawner = container.InstantiateComponentOnNewGameObject<FlyingTextSpawner>("CustomMissTextSpawner"); Debug.Log("Text Spawner Attempted"); } // songController = FindObjectOfType<GameSongController>(); var sceneSetup = BS_Utils.Plugin.LevelData; if (textSpawner == null) { Debug.Log("Null TextSpawner, breaking"); yield break; } //Set Text Spawner Properties (fontSize, Color, Shake) textSpawner.SetField("_fontSize", Settings.FontSize); textSpawner.SetField("_shake", Settings.Shake); textSpawner.SetField("_color", Settings.TextColor); audio = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault(); if (BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.practiceSettings != null) { SpawnText("Practice Mode. \n" + "Ignoring Lyrics", 2f); yield break; } if (BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul != 1f) { SpawnText("NonStandard Speed. \n" + "Ignoring Lyrics", 2f); yield break; } IBeatmapLevel level = sceneSetup.GameplayCoreSceneSetupData.difficultyBeatmap.level; List <Subtitle> subtitles = new List <Subtitle>(); Debug.Log($"[Beat Singer] Corresponding song data found: {level.songName} by {level.songAuthorName} / {level.songSubName}."); if (LyricsFetcher.GetLocalLyrics(sceneSetup.GameplayCoreSceneSetupData.difficultyBeatmap.level, subtitles)) { Debug.Log("[Beat Singer] Found local lyrics."); Debug.Log($"[Beat Singer] These lyrics can be uploaded online using the ID: \"{level.GetLyricsHash()}\"."); // Lyrics found locally, continue with them. SpawnText("Lyrics found locally", 3f); } else { Debug.Log("[Beat Singer] Did not find local lyrics, trying online lyrics..."); // When this coroutine ends, it will call the given callback with a list // of all the subtitles we found, and allow us to react. // If no subs are found, the callback is not called. yield return(StartCoroutine(LyricsFetcher.GetOnlineLyrics(level, subtitles))); if (subtitles.Count != 0) { goto FoundOnlineLyrics; } yield return(StartCoroutine(LyricsFetcher.GetMusixmatchLyrics(level.songName, level.songAuthorName, subtitles))); if (subtitles.Count != 0) { goto FoundOnlineLyrics; } yield return(StartCoroutine(LyricsFetcher.GetMusixmatchLyrics(level.songName, level.songSubName, subtitles))); if (subtitles.Count != 0) { goto FoundOnlineLyrics; } yield break; FoundOnlineLyrics: SpawnText("Lyrics found online", 3f); } StartCoroutine(DisplayLyrics(subtitles)); }