INetworkScriptableFactory

Base interface for all network-aware factories. Extends IScriptableFactory by adding a GlobalObjectIdHash property that identifies the factory's prefab within Unity Netcode's network prefab system.

Definition

Namespace: Paragon.Core.Network Assembly: Paragon.dll

public interface INetworkScriptableFactory : IScriptableFactory

Extends: IScriptableFactory

Remarks

INetworkScriptableFactory is the non-generic entry point for the network factory interface hierarchy. It adds a single property — GlobalObjectIdHash — which maps to the NetworkObject.GlobalObjectIdHash on the factory's prefab. This hash is used by Netcode to:

  1. Identify prefabs during network spawn replication

  2. Register custom prefab handlers via NetworkManager.PrefabHandler

  3. Match spawn requests between server and client

The hash is typically extracted from the prefab's NetworkObject component during factory initialization and cached for the factory's lifetime.

Quick Lookup

Goal
How

Get Netcode prefab hash

factory.GlobalObjectIdHash

Check if factory is network-aware

factory is INetworkScriptableFactory

Use as regular factory

Cast to IScriptableFactory (inherited)

Properties

GlobalObjectIdHash

The NetworkObject.GlobalObjectIdHash of the factory's prefab. Used by Netcode for prefab identification and custom prefab handler registration.

Returns: The hash value from the prefab's NetworkObject component.

Implementation Requirements

When implementing INetworkScriptableFactory, you MUST:

  1. Return the GlobalObjectIdHash from the factory's prefab NetworkObject

  2. Ensure the prefab has a NetworkObject component attached

  3. Satisfy all IScriptableFactory requirements (lifecycle, gameObject, transform)

circle-info

In practice, subclass NetworkScriptableFactory<TObject> rather than implementing this interface directly. It extracts the hash from the prefab automatically during Initialize().

Common Pitfalls

circle-exclamation
circle-exclamation

See Also

Last updated