#SpawnablePrefabs is null on NetworkManager

64 messages · Page 1 of 1 (latest)

delicate eagle
#

Since updating to the newest version and upgrading to Pro, I have an issue with the networkmanager.
When starting the game, everything seems fine and the networkmanager has the "SpawnablePrefabs" filled. But when changing scenes, the console writes:

SpawnablePrefabs is null on NetworkManager. Select the NetworkManager in scene ... and choose a prefabs file. Choosing DefaultPrefabObjects will automatically populate prefabs for you.
UnityEngine.Debug:LogError (object)

When debugging and when changing the scene, the field is empty, but only when changing the scene.
I tried "Refresh Default Prefabs" and "Reserialize Network Objects", i also tried the Prefab Object Generator. I tried deleting and recreating the networkmanager but it comes back every time.

What could be the issue?

FYI i am starting the game with the networkmanager in the starting scene (main menu). then i go to a "real" gaming scene.

carmine bobcat
#

Hey there, is the network manager solely in the starting scene? And is it set to don't destroy on load?

delicate eagle
#

what do you mean by "solely"? the are other things like the hud for the main menu.
Its set to dont destroy on load

carmine bobcat
delicate eagle
#

yes

#

the other scenes are clean

#

it worked with the old version before updating

carmine bobcat
#

Gotcha, if you unset the SpawnablePrefabs field on the NetworkManager (it should automatically reset) and then save and restart the Unity editor, does it fix it?

delicate eagle
#

sadly no

#

i also tried deleting the defaultprefabs file

#

but no

#

its weird, because when debugging and inspecting the field, it is almost always well filled

#

just when switching scenes it becomes null for "some" reason

carmine bobcat
#

It is indeed most peculiar 🤔

#

What does the scene changing code look like?

delicate eagle
#
    private void LoadScene(SceneType scene, NetworkObject player, bool allowStacking = false, bool localPhysics = false)
    {
        var name = GetSceneName(scene);
        var sceneLookupData = new SceneLookupData(name);
        var sceneLoadData = new SceneLoadData(sceneLookupData);
        sceneLoadData.PreferredActiveScene = new PreferredScene(sceneLookupData);
        sceneLoadData.Options.AllowStacking = allowStacking;
        sceneLoadData.MovedNetworkObjects = new[] { player };
        sceneLoadData.ReplaceScenes = ReplaceOption.OnlineOnly;
        if (localPhysics) sceneLoadData.Options.LocalPhysics = LocalPhysicsMode.Physics3D;
        sceneLoadData.Options.AutomaticallyUnload = true;

        //InformPlayerSceneChangedStart(player.LocalConnection);
        InstanceFinder.SceneManager.LoadConnectionScenes(player.Owner, sceneLoadData);
        CurrentlyLoadingPlayers.Add(player);
        //InstanceFinder.SceneManager.OnClientPresenceChangeEnd += (obj) => SceneManager_OnClientPresenceChangeEnd(player, obj);
    }
carmine bobcat
#

This is happening as a host currently, right?

delicate eagle
#

as a host yes. one sec ill try as a client too

carmine bobcat
#

Could you try creating a SinglePrefabObjects asset and putting it in the NetworkManager to see if it also gets unset?

delicate eagle
delicate eagle
#

yea still happening

carmine bobcat
#

Hmm, when do you call the scene load?

delicate eagle
#

well

#

sry for late reply, went to bed yesterday

#

when a new player joines, he gets registered etc. and then send to his scene

#

ive checked again, if any of the code may be runing as client and not server, but it seems alright

#

im trying to delete the whole fishnet and reimporting it again

delicate eagle
#

didnt work

delicate eagle
#

well im running out of ideas. ive even changed the unity version but it didnt help

carmine bobcat
#

Yeah, I'm also unsure what can be causing it. @white summit will hopefully be able to assist.

#

Here is a summary:
Since upgrading to FishNet Pro (and the latest version), the NetworkManager is losing its SpawnablePrefabs reference during scene transitions. The field appears correctly populated in the inspector at start, but throws a "SpawnablePrefabs is null" error specifically when loading a new scene.

Environment & Setup:

Unity Version: Recently updated (tried multiple versions to fix).

Networking: FishNet Pro.

Architecture: The NetworkManager exists only in the Main Menu scene and is set to DontDestroyOnLoad.

Workflow: When a player joins, the server calls LoadConnectionScenes to move them from the menu to a "gameplay" scene.

Troubleshooting Already Attempted:

Manual Refreshes: Tried "Refresh Default Prefabs," "Reserialize Network Objects," and the Prefab Object Generator.

Asset Swapping: Deleted/recreated the NetworkManager and tried using a SinglePrefabObjects asset instead of the default.

Reinstallation: Deleted and reimported the FishNet folder entirely.

Logic Check: Confirmed the issue happens for both Host and Client. The user verified the code is not accidentally running client-side logic on the server.

The Code Triggering the Load:
The user is using InstanceFinder.SceneManager.LoadConnectionScenes with SceneLoadData. The error occurs exactly when this transition triggers.

Key Observation: The SpawnablePrefabs field is populated while in the initial scene but becomes null the moment the scene change logic executes, despite the NetworkManager persisting via DontDestroyOnLoad.
delicate eagle
#

The SpawnablePrefabs field is populated while in the initial scene but becomes null the moment the scene change logic executes, despite the NetworkManager persisting via DontDestroyOnLoad.
and one addition: it then becomes populated again

white summit
#

What is going on, sorry?

carmine bobcat
delicate eagle
#

Okay, i have tried reinstalling&updating unity, tried deleting the whole project and reinitializing the project (a version before ive updated), deleted the cache and removing unnecessary scripts - nothing helped

#

im getting desperate

#

some of my code must be working in the old version but with the update getting buggy

carmine bobcat
#

Does importing the old version fix it?

delicate eagle
#

Using the old Version it works

#

Or do you mean updating and 'down'-dating again?

#

Currently im trying if delaying the joining process would help, but no

white summit
#

Need to know if going to a couple versoins ago, 4.6.20, fixes it.

delicate eagle
#

downgrading from newest version - or upgrading from the version where it still worked?
shouldnt matter, right?

white summit
#

what version did it work on? does it work on 4.6.20, does it work on 4.6.22?

delicate eagle
#

previous version was 4.5.5 - as written in package.json - there it worked fine
4.6.22 doesnt work
ive checked 4.6.20 now, and there is still the problem

white summit
#

Ah okay.

#

That's way too far back to troubleshoot. The value shouldn't simply be going null though.

#

Make sure its actually referencing the defaultprefabobjects in your projects /files tab. If you arent sure, delete all instances of that file and it will auto-regen

delicate eagle
#

yea its an pretty old version i know. always postponed the update ( now i know why 😄 )

#

yea deleteing it didnt help

#

its weird, because it is set - and then when the scene changes it is not - and after that its set again

delicate eagle
#

what would be smartest thing to do now? i cant replicate the error, so scripting a new lobby system etc. .. i dont know.
should i just use the old version? where can i get the pro version for that?

white summit
#

I can give you the old version but there's no known bugs around what you're describing in the newest release.

#

Its more likely something was fixed and you were able to exploit unknowingly in the old version. Or maybe just a caching error.

#

Check your DMs for the older package.

white summit
#

But def please try to figure out what the leading conditions are so this can be resolved properly if a bug

delicate eagle
#

thank you very much. i will try to figure this out

#

i can post an update on this when i know whats the issue

delicate eagle
#

we couldnt figure out what the problem is, but we worked around it by reprogramming some part of the scene handling. we got some bugs from the rework but the error is gone now

white summit
#

That is interesting... What did you change?

delicate eagle
#

at this point i dont even know anymore - we deleted and recoded a lot of the code which is working with the scene management, because we couldnt get it to work right

#

now it works, except local physics, but thats a todo for tomorrow

white summit
#

Is it possible you're spawning NetworkManagers with null spawnable prefabs?