Search Unity

Question Blocked particles and animations

Discussion in 'Animation' started by Andrea127, Nov 11, 2022.

  1. Andrea127

    Andrea127

    Joined:
    Oct 11, 2022
    Posts:
    13
    In my 2d game i've implemented a pause menu than can turn you to the main menu, but i when click the menu button the particles in the main menu doesn't start even the transition to the game scene (from the menu scenes). Someone can help? Thanks!!
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
  3. Andrea127

    Andrea127

    Joined:
    Oct 11, 2022
    Posts:
    13
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class MainMenu : MonoBehaviour
    7. {
    8.     public Animator transition;
    9.     public float transitionTime = 1f;
    10.  
    11.     public void PlayGame()
    12.     {
    13.         LoadLevel();
    14.         /*Carica la prossima scene facendo quella attuale + 1(ho settato nei build settings che la main menu è la 0 ed il game 1)*/
    15.         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
    16.     }
    17.  
    18.     /* couroutine per l'animazione crossFade*/
    19.     IEnumerator LoadLevel() {
    20.  
    21.         transition.SetTrigger("Start"); //start sarebbe il parametro usato nella animazione per dare modo all'animazione di partire
    22.  
    23.         yield return new WaitForSeconds(transitionTime);
    24.     }
    25.  
    26.     public void QuitGame()
    27.     {
    28.         Debug.Log("QUIT!");
    29.         Application.Quit();
    30.     }
    31. }
     
  4. Andrea127

    Andrea127

    Joined:
    Oct 11, 2022
    Posts:
    13
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class Pausa : MonoBehaviour
    7. {
    8.     public static bool GameIsPaused = false;
    9.     public GameObject pauseMenuUI;
    10.  
    11.  
    12.     public void openClosePauseMenu(){
    13.     if (GameIsPaused)
    14.      {
    15.         Resume();
    16.  
    17.      }else
    18.      {
    19.         Pause();
    20.      }
    21.     }
    22.     public void Resume()
    23.     {
    24.         pauseMenuUI.SetActive(false);
    25.         Time.timeScale = 1f;
    26.         GameIsPaused = false;
    27.     }
    28.  
    29.     public void Pause()
    30.     {
    31.         pauseMenuUI.SetActive(true); //spunto il game object relativo al menu
    32.         Time.timeScale = 0f;
    33.         GameIsPaused = true;
    34.     }
    35.  
    36.     public void LoadMenu()
    37.     {
    38.         SceneManager.LoadScene(0);
    39.     }
    40.  
    41.     public void QuitGame()
    42.     {
    43.         Debug.Log("QUIT");
    44.         Application.Quit();
    45.     }
    46. }
     
  5. Andrea127

    Andrea127

    Joined:
    Oct 11, 2022
    Posts:
    13
    i also have a video of the problem, where can i upload it?
     
  6. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
    youtube is easiest to view, can make it unlisted if need to.
     
  7. Andrea127

    Andrea127

    Joined:
    Oct 11, 2022
    Posts:
    13
  8. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438