You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
44
44
45
45
- Added `SinglePlayerTransport` that provides the ability to start as a host for a single player network session. (#3473)
46
46
- When using UnityTransport >=2.4 and Unity >= 6000.1.0a1, SetConnectionData will accept a fully qualified hostname instead of an IP as a connect address on the client side. (#3441)
47
+
- Added `NetworkPrefabInstanceHandlerWithData<T>`, a variant of `INetworkPrefabInstanceHandler` that provides access to custom instantiation data directly within the `Instantiate()` method. (#3430)
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs
+85-49Lines changed: 85 additions & 49 deletions
Original file line number
Diff line number
Diff line change
@@ -58,6 +58,12 @@ public uint PrefabIdHash
58
58
}
59
59
}
60
60
61
+
/// <summary>
62
+
/// InstantiationData sent during the instantiation process.
63
+
/// Available to read as T parameter to <see cref="NetworkPrefabInstanceHandlerWithData{T}.Instantiate(ulong, Vector3, Quaternion, T)"/> for custom handling by user code.
64
+
/// </summary>
65
+
internalbyte[]InstantiationData;
66
+
61
67
/// <summary>
62
68
/// All <see cref="NetworkTransform"/> component instances associated with a <see cref="NetworkObject"/> component instance.
63
69
/// </summary>
@@ -2857,6 +2863,12 @@ public bool SpawnWithObservers
2857
2863
set=>ByteUtility.SetBit(refm_BitField,10,value);
2858
2864
}
2859
2865
2866
+
publicboolHasInstantiationData
2867
+
{
2868
+
get=>ByteUtility.GetBit(m_BitField,11);
2869
+
set=>ByteUtility.SetBit(refm_BitField,11,value);
2870
+
}
2871
+
2860
2872
// When handling the initial synchronization of NetworkObjects,
2861
2873
// this will be populated with the known observers.
2862
2874
publiculong[]Observers;
@@ -2884,6 +2896,7 @@ public struct TransformData : INetworkSerializeByMemcpy
2884
2896
2885
2897
publicintNetworkSceneHandle;
2886
2898
2899
+
internalintSynchronizationDataSize;
2887
2900
2888
2901
publicvoidSerialize(FastBufferWriterwriter)
2889
2902
{
@@ -2945,9 +2958,29 @@ public void Serialize(FastBufferWriter writer)
/// Interface for customizing, overriding, spawning, and destroying Network Prefabs
8
+
/// Used by <see cref="NetworkPrefabHandler"/>
9
+
/// </summary>
10
+
publicinterfaceINetworkPrefabInstanceHandler
11
+
{
12
+
/// <summary>
13
+
/// Client Side Only
14
+
/// Once an implementation is registered with the <see cref="NetworkPrefabHandler"/>, this method will be called every time
15
+
/// a Network Prefab associated <see cref="NetworkObject"/> is spawned on clients
16
+
///
17
+
/// Note On Hosts: Use the <see cref="NetworkPrefabHandler.RegisterHostGlobalObjectIdHashValues(GameObject, List{T})"/>
18
+
/// method to register all targeted NetworkPrefab overrides manually since the host will be acting as both a server and client.
19
+
///
20
+
/// Note on Pooling: If you are using a NetworkObject pool, don't forget to make the NetworkObject active
21
+
/// via the <see cref="GameObject.SetActive(bool)"/> method.
22
+
/// </summary>
23
+
/// <remarks>
24
+
/// If you need to pass custom data at instantiation time (e.g., selecting a variant, setting initialization parameters, or choosing a pre-instantiated object),
0 commit comments