private IEnumerator WaitLoadGame() { _screenFader.Fade(1); yield return(new WaitForSeconds(_wait)); GameManager.GetInstance().LoadGame(); }
// Use this for initialization void OnSceneLoaded(Scene scene, LoadSceneMode mode) { GetSceneComponents(); bool titleScreen = scene.name == "TitleScreen"; if (titleScreen) { // For fading into the title screen if (screenFader.opacity > 0) { screenFader.Fade(0, 1); } // Make the start button fade into the game scene Button startButton = GameObject.Find("StartButton").GetComponent <Button>(); startButton.onClick.AddListener(fadeIntoGameScene); } // Basically reset the game when loading into the game scene bool gameScene = scene.name == gameSceneName; if (gameScene) { // Find the player train and watch for the trains' deaths playerTrain = GameObject.FindObjectOfType <PlayerTrain>(); trainsInScene = new List <TrainController>(GameObject.FindObjectsOfType <TrainController>()); foreach (TrainController train in trainsInScene) { train.Died.AddListener(OnTrainDied); } screenFader.FadeBegin.RemoveAllListeners(); screenFader.FadeEnd.RemoveAllListeners(); if (screenFader.opacity > 0 && !screenFader.isFading) { screenFader.Fade(0, 1); } musicPlayer.Stop(); musicPlayer.clip = stageMusic; musicPlayer.PlayDelayed(1f); } Debug.Log("On Scene Loaded!"); }
public void Ride() { if (IsTargetable) { ScreenFader.Fade(null, () => { // Attach the camera to the cart. if (attachCamera != null) { attachCamera.Attach(); } else { Debug.LogError("CartClick: AttachCamera is null."); } }, () => { // Start the cart running its path. if (runWithPath != null) { runWithPath.enabled = true; } else { Debug.LogError("CartClick: RunWithPath is null."); } }); } }
public IEnumerator waitingBeforeFading(float time) { yield return(new WaitForSeconds(time)); _fader.Fade(_fadeDirection); _fadeDirection *= -1; }
public void fadeScreen() { GameObject fader = GameObject.Find("ScreenFader"); ScreenFader fadingScript = fader.GetComponent <ScreenFader>(); fadingScript.Fade(); }
void DrawNewElements() { ScreenFader fader = target as ScreenFader; GUILayoutOption widthLimit = GUILayout.MaxWidth(100); // Target Opacity section GUILayout.BeginHorizontal(); GUILayout.Label("Target Opacity"); opacityText = GUILayout.TextField(opacityText, 10, widthLimit); float.TryParse(opacityText, out targetOpacity); GUILayout.EndHorizontal(); // Duration section GUILayout.BeginHorizontal(); GUILayout.Label("Duration"); durationText = GUILayout.TextField(durationText, 10, widthLimit); float.TryParse(durationText, out duration); GUILayout.EndHorizontal(); if (GUILayout.Button("Fade")) { fader.Fade(duration, targetOpacity, Color.white); // fader = GameObject.FindObjectOfType<ScreenFader>(); //if (fader != null) // Debug.Log("Fader found!"); } }
void StartTeleportation(Player toTeleport) { toTeleport.canMove = false; toTeleport.rigidbody.velocity = Vector2.zero; screenFader.FadeEnded.AddListener(TeleportToScene); screenFader.Fade(teleportDuration, 1, Color.white); }
protected virtual void OnDisable() { isEnd = false; ScreenFader.Fade(null, () => { transform.position = startPosition; transform.rotation = startRotation; if (attachCamera != null) { attachCamera.enabled = false; } }, () => { if (PathEnded != null) { PathEnded.Invoke(); } }); }
void OnSceneLoaded(Scene scene, LoadSceneMode mode) { bool titleScreen = scene.name == "titleScreen"; if (titleScreen) { // For fading into the title screen if (screenFader.opacity > 0) { screenFader.Fade(0, 1); } // Make the start button fade into the game scene Button startButton = GameObject.Find("StartGameButton").GetComponent <Button>(); startButton.onClick.AddListener(fadeIntoGameScene); } // Basically reset the game when loading into the game scene bool gameScene = scene.name == "game"; if (gameScene) { screenFader.FadeBegin.RemoveAllListeners(); screenFader.FadeEnd.RemoveAllListeners(); if (screenFader.opacity > 0) { screenFader.Fade(0, 1); } GetGameSceneComponents(); musicPlayer.Stop(); musicPlayer.clip = stageMusic; musicPlayer.PlayDelayed(1f); planets = GameObject.FindObjectsOfType <Planet>(); SubscribeToGameSceneEvents(); } Debug.Log("On Scene Loaded!"); bool endingScene = scene.name == victoryScene || scene.name == gameOverScene; if (endingScene) { // Do a fade in so the player can properly see the end scene, and when that's // done, it's officially game over Debug.Log("Reached ending scene!"); screenFader.Fade(0, fadeInDuration); screenFader.FadeEnd.AddListener(GameOver.Invoke); // Make sure that the yes and no buttons fade out the music when they're selected // before loading scenes Button yesButton = GameObject.Find("YesButton").GetComponent <Button>(); Button nobutton = GameObject.Find("NoButton").GetComponent <Button>(); UnityAction fadeIntoGameScene = new UnityAction(FadeIntoGameScene); UnityAction fadeIntoTitleScreen = new UnityAction(FadeIntoTitleScreen); yesButton.onClick.AddListener(fadeIntoGameScene); nobutton.onClick.AddListener(fadeIntoTitleScreen); } }
// Use this for initialization void Start() { fader = GetComponent <ScreenFader>(); fader.Fade(1f, 0f, 0.3f); }
// Use this for initialization void Start() { fader = GetComponent<ScreenFader>(); fader.Fade(1f, 0f, 0.3f); }