Question about registering Network Prefabs

My list on the Network Manager is growing quite large. The NetworkPrefabs list doesn’t seem to be accessible, conventionally through code and I haven’t seen anyone automate registering prefabs.

I considered extending NetworkPrefabs to register prefabs with a certain tag or script or read from a ScriptableObject DB that automatically registers prefabs. I am wondering if there is a reason to not do this. It seems like the kind of thing that would have been done before or even built in.

Perhaps I am missing something. Is the best out-of-the-box solution really to drag and drop items into the editor?

It’s unfortunately currently the only way to do it. Anything else would need modification of the source code.

Alright. That’s what I was afraid of. As a result, I’ve adopted a model of using super generalized prefab such as NetworkProjectile that, OnNetworkSpawn, fills out the rest of the information based on ID. More infrastructure code, but with something like a bullet-he’ll that has dozens or hundreds of projectiles that all have different behaviors, it’s much better to simply register one prefab.

Are there any plans to change this? I’m also running into a similar situation as the op and wouldn’t want to invest in some workaround if Unity is planning to change this at some point in the near future.

Yes we had a discussion about this recently and we’ll try to figure out a better solution.

I’m building an app that loads prefabs from asset bundles at runtime, so I CAN’T add them in the editor. Looks like I’ll need to find another networking solution until this is fixed. :frowning:

2 Likes