Issues with Coroutine

Hello everybody , firstly I’m sorry for my bad english I have a issue with my script in coroutine , after “while” the script not read the next instructions I don’t know why

    private void Update() {
        if (isConnected == false)
            return;

        Scene scene = SceneManager.GetActiveScene ();
        if (scene.name == "Map1")
            ScreenLoaded = true;
}
    IEnumerator OnAskName(string[] data) {
        while (ScreenLoaded == false) {
            Debug.Log ("En attente du chargement");
            yield return new WaitForSecondsRealtime (0.100f);
        }
        Debug.Log ("test?");
        ourClientId = int.Parse(data[1]);

        // Send our name to the server

        Send ("NAMEIS|" + playerName, reliableChannel);


        // Create all the other players
        for (int i = 2; i < data.Length - 1; i++) {
            Debug.Log ("for");
            string[] d = data [i].Split ('%');
            if(d[0] != "TEMP")
                SpawnPlayer (d [0], int.Parse (d [1]));
        }

        yield return null;
    }

debug.log(“test?”) is not read

thanks in advance for your help .

If the coroutine is fired on a gameobject in the old scene it will stop executing when the gameobject is inactive/destroyed

Either ScreenLoaded is never true or possibly your coroutine is killed off while it’s still running the while loop.

However, Unity includes a way to subscribe to a delegate when a scene finishes loading. You should use that instead of trying to do your own way of checking.

thanks for your help I fixed my problem .