WHK-Battlesim / Battlesim

Der WHK-Battlesim nutzt die Wilhelmshöher Kriegskarten, um historische Schlachten zu simulieren und zu visualisieren.
https://whk-battlesim.github.io/
MIT License
3 stars 0 forks source link

check loading/start function order #25

Closed lukaswagner closed 5 years ago

lukaswagner commented 5 years ago

make sure if start and/or awake are called before the scene loads. this is necessary to properly implement #23

lukaswagner commented 5 years ago

It seems all the start/awake functions of the loaded scene are only called after the scene is already set as loaded.

Test code:

public class Loader : MonoBehaviour
{
    private AsyncOperation _asyncOperation;

    void Awake()
    {
        Debug.Log("Loader.Awake()");
    }

    void OnEnable()
    {
        Debug.Log("Loader.OnEnable()");
    }

    void Start ()
    {
        Debug.Log("Loader.Start()");

        _asyncOperation = SceneManager.LoadSceneAsync("ContentScene");
    }

    void Update ()
    {
        Debug.Log("Loading progress: " + _asyncOperation.progress);
    }
}
public class Content : MonoBehaviour {

    void Awake()
    {
        Debug.Log("Content.Awake()");
    }

    void OnEnable()
    {
        Debug.Log("Content.OnEnable()");
    }

    void Start ()
    {
        Debug.Log("Content.Start()");

        Thread.Sleep(1000);

        Debug.Log("Content.Start() finished");
    }
}

The order of logs is as follows: image