Search Unity

Overwriting the same path as another open scene is not allowed

Discussion in 'Editor & General Support' started by PoitreqmDev, Jun 13, 2018.

  1. PoitreqmDev

    PoitreqmDev

    Joined:
    May 8, 2018
    Posts:
    1
    Hello guys,
    faced yesterday with such a problem, if i want to save anything in my scene, i get error:

    If i open my project, it waiting me

    If i will start project:
    the same appears only already IS LOADED, which I can not close :/

    Today we were able to find out what was the problem. I disabled the scripts one by one to see what was going on.The problem was the script that creates my character on stage. The script is tied to the camera. If you turn it off, everything works fine.
    P.S.All because of the line in the script that is tied to the character. But why and how to bypass it and with all this-before this was not
    Code (CSharp):
    1.     private void OnBecameInvisible()
    2.     {
    3.         Physics2D.IgnoreLayerCollision(8, 9, false);
    4.         RestartClick.defaultScore = 5;
    5.         SceneManager.LoadScene(SceneManager.GetActiveScene().name); // because of this all i trying and SceneManager.LoadScene(0) - same
    6.         Destroy(gameObject);
    7.     }
     
    Last edited: Jun 13, 2018
  2. marcozakaria

    marcozakaria

    Joined:
    Sep 17, 2017
    Posts:
    23
    I had the same problem it was because of "OnBecameInvisible()" when i commented it i stop seeing the isloading thing ,I think it was like code race condition problem.

    I fix it by this checking with a boolean
    Code (CSharp):
    1. private void OnBecameInvisible()
    2.     {
    3.         if (!GameManager.instance.gameOver)
    4.         {
    5.             GameManager.instance.ReloadLevel();
    6.         }  
    7.     }
    Code (CSharp):
    1.     public bool gameOver = false;
    2.  
    3.     public void ReloadLevel()
    4.     {
    5.         gameOver = true;    
    6.         StartCoroutine(RestarCurrentLevel());
    7.     }
    8.  
    9.     IEnumerator RestarCurrentLevel()
    10.     {
    11.         yield return new WaitForSeconds(0.1f);
    12.         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
    13.     }
    14.  
     
    Last edited: Jan 14, 2019
    Mulberg and cheesepant like this.