Sometimes Game Scene is loading twice

So I working on a Multiplayer game. where the user selects environment Dessert/Forest and has a match
If no player found then the player will have a match with AI

Only in the case of match with realplayer sometimes my environment scene is getting loaded twice, which is causing so many other things to break.

I am using this coroutine to load the scene. and I have checked this isn't calling 2 times.

IEnumerator ProgressBar()
{
#if UNITY_EDITOR
yield return new WaitForSeconds(0.5f);
#endif
Debug.Log("inside progress bar");


Time.timeScale = 1;
async = SceneManager.LoadSceneAsync(loadScene);
async.allowSceneActivation = false;

while (!async.isDone)
{

if (async.progress >= 0.9f)
{
break;
}

yield return null;
}

yield return new WaitForSeconds(0.5f);
text3.color = new Color32(255, 255, 255, 255);

yield return new WaitForSeconds(0.5f);
text2.color = new Color32(255, 255, 255, 255);

yield return new WaitForSeconds(0.5f);
text1.color = new Color32(255, 255, 255, 255);

yield return new WaitForSeconds(0.5f);
text3.gameObject.SetActive(false);
text2.gameObject.SetActive(false);
text1.gameObject.SetActive(false);
textGo.gameObject.SetActive(true);

yield return new WaitForSeconds(0.5f);

async.allowSceneActivation = true;
yield return async;
}

Comments

  • If you are not yet using the latest version of PUN 2 (or PUN Classic), please update first.
    If it still happens, we will have a closer look.
  • Tobias said:

    If you are not yet using the latest version of PUN 2 (or PUN Classic), please update first.
    If it still happens, we will have a closer look.

    I am using pun v1
  • I would suggest updating to PUN 2, if you're not "done" yet with development.
    It may solve the issue, too.

    Right now, I have no indication what's going on. To debug, I suggest to place Debug.Log() messages strategically to log when you begin loading scenes. That way, we may find out what are the first and second trigger to load the same scene twice.
  • edited April 19

    please let me know.
    Tobias said:

    I would suggest updating to PUN 2, if you're not "done" yet with development.
    It may solve the issue, too.

    Right now, I have no indication what's going on. To debug, I suggest to place Debug.Log() messages strategically to log when you begin loading scenes. That way, we may find out what are the first and second trigger to load the same scene twice.

    I have updated to PUN 2. but still, the same issue is coming.
    Here are the scripts
    OpponentSearchScreen.cs MultiplayerManager.cs MyExtension.cs
  • @Tobias, please help regarding this issue
  • Hi,

    the problem is likely on your end, I just tested with the Basic tutorial scene, which uses scene loading and it works fine.

    to pin point the problem, make a test scene, which simply loads another scene, make it as minimal as possible and work from there, if you can repro this with a simple test, package them scenes and the scripts you used and send them to us, then we'll be able to check if we can replicate this issue and address it if that's the case.

    Bye,

    Jean
Sign In or Register to comment.