Vixen
dd8b0a81
csharp
public static class NetworkPrefabContent

Fills a NetworkPrefabRegistry out of Assets, by label.

Read the guide page for this →

Remarks

What makes "networked prefab" something an asset is rather than something a start-up path remembers to say. Register is a call, and a call has to be written once per prefab on every peer that could be told to spawn it — so the failure mode is a client that was never told about the crate, receives the spawn, and drops it. A label is a property of the content, so both ends read the same list out of the same build and neither maintains it.

⚠ Both peers still build the registry independently, and that is the design rather than an accident. A prefab's id is the hash of its address ([08](../../../docs/plan/08-asset-pipeline-and-addressables.md)), so a server and a client that register the same addresses agree without a handshake. What this changes is only where the list of addresses comes from; what it does not change is that nothing about the registry is sent.

⚠ A bad label is a problem and a bad address is an exception. A .vxgroup broad enough to sweep a texture in is a content mistake, so the rest registers and the problem is named. An address that is not in this build's content catalog at all is the caller being wrong — a typo in a hand-written list — and swallowing it would turn that typo into a prefab that silently can never be spawned.

The templates are held and the assets are not. A Prefab is a template world, built once per prefab and stamped out for the life of the build — so this releases its AssetHandle`1 as soon as the template is captured. What a prefab's components point at — a mesh, a material, a sound — is an AssetReference inside the component and is loaded on the ordinary handle path by whoever draws it, which is the same division DefinitionContent makes.

⚠ A prefab that arrives this way has exactly one networked node today, whatever its author marked. NetworkPrefabRegistry reads the marker off the template as NetworkId, and a compiled scene may only name a component that is [Component] and [DataContract] — which NetworkId is not, so SceneContent.Capture drops it without a word. It is asserted in this assembly's tests rather than left to be found, because the symptom is a turret whose barrel simply never replicates. See the README.

Fields and properties (1)

  • public const string Label

    The label a content build puts on the group its networked prefabs live in.

Methods (3)

Used by (2)

  • NetworkPrefabContentTestsVixen.Net.Engine.Content.Tests
  • NetworkRulesContentTestsVixen.Net.Engine.Content.Tests