- Home /
Question by
Viwo04 · May 26 at 11:00 PM ·
animationvisual studioscene-switchingblock
How to turn off scene transition animations
How to turn off scene transition animations? I would like to disable the animation ONLY for the RestartGame command. so that the animation works for other commands. Is there any script for such a thing? this is my animation script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LevelLoader : MonoBehaviour
{
public Animator transition;
public float transitionTime = 1f;
public void LoadNextLevel()
{
StartCoroutine(LoadLevel(SceneManager.GetActiveScene().buildIndex + 1));
}
public AudioClip impact;
IEnumerator LoadLevel(int LevelIndex)
{
transition.SetTrigger("Start");
yield return new WaitForSeconds(transitionTime);
SceneManager.LoadScene(LevelIndex);
yield return new WaitForSeconds(0.3f);
AudioSource.PlayClipAtPoint(impact, transform.position);
}
}
and this is my RestartGame command which is in another script:
public void RestartGame()
{
SceneManager.LoadScene(PlayerPrefs.GetInt("SavedScene"));
}
Comment
you are exactly doing that whenever you call RestartGame() Function it will load without triggering your LoadLevel IEnumerator
Your answer
![](https://koobas.hobune.stream/wayback/20220613061031im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Stop animation in Animation Controller 0 Answers
Can the animation editor create local rotational data? 3 Answers
Adding animation clips via script 2 Answers