#How to reliably know when a scene is loaded?

1 messages · Page 1 of 1 (latest)

patent timber
#

Ive been using NetworkManager.SceneManager.OnLoadEventCompleted, but this is not reliable, as this only fires on the Server/Host. I load a new scene and then need to load data for players that exists only in that scene. For example I connect to a lobby, switch scene, and then need to generate a UI for the Inventory that didnt exist before. I tried using Awake/Start as well but nothing seems to work, I just cant reliably get something running when a scene is loaded

patent timber
#

This does not get fired on a client at all. I implemented it the same way as in the docs, add the event in OnEnable, and log in the event method. It never gets calles. Actually, OnEnabled does run, but OnSceneLoaded never does. There is nothing loggign OnSceneLoaded: ...In the console, except for the server, which works fine. But thats not what I need, I need the client

sharp stump
#

show code?

patent timber
#
    void OnEnable()
    {
        Debug.Log("OnEnable called");
        SceneManager.sceneLoaded += OnSceneLoaded;
    }
    void OnDisable()
    {
        Debug.Log("OnDisable");
        SceneManager.sceneLoaded -= OnSceneLoaded;
    }
    void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        Debug.Log("OnSceneLoaded: " + scene.name);
        Debug.Log(mode);
    }

sharp stump
#

You would subscribe to sceneloaded on something before the scene is loaded

dawn light
patent timber
#

Its the new scene on the server, its before a scene loads on the client I believe, but because it doesnt "load" the scene but rather "syncs" it I think it never actually counts as a scene transtiton, I did find a super hacky way to do what I need tho