Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Managing scene loading myself

Discussion in 'Netcode for GameObjects' started by BruceKristelijn, Jul 30, 2022.

  1. BruceKristelijn

    BruceKristelijn

    Joined:
    Apr 28, 2017
    Posts:
    57
    Hi! I really want to preload some network scenes but keep them unloaded and spawn all objects when these are needed. Is there a way for this? I used reflection to call Scene and Spawnmanager methods but this is not a proper way of course.

    Any help would be appreciated!

    Right now I loop over new network objects and call this code found here:
    Code (CSharp):
    1.                         object id = NetworkManager.Singleton.SpawnManager.GetType().GetMethod("GetNetworkObjectId", flags).Invoke(NetworkManager.Singleton.SpawnManager, null);
    2.                         var method = NetworkManager.Singleton.SpawnManager.GetType().GetMethods(flags).Where(o => o.Name == "SpawnNetworkObjectLocally").ToList()[0];
    3.                         method.Invoke(NetworkManager.Singleton.SpawnManager, new object[] { obj, id, true, false, NetworkManager.Singleton.ServerClientId, true });
     
unityunity