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
@@ -23,6 +23,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
23
23
24
24
- Added `SinglePlayerTransport` that provides the ability to start as a host for a single player network session. (#3473)
25
25
- 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)
26
+
- 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
+28-3Lines changed: 28 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,12 @@ public uint PrefabIdHash
57
57
}
58
58
}
59
59
60
+
/// <summary>
61
+
/// InstantiationData sent during the instantiation process.
62
+
/// Available to read as T parameter to <see cref="NetworkPrefabInstanceHandlerWithData{T}.Instantiate(ulong, Vector3, Quaternion, T)"/> for custom handling by user code.
63
+
/// </summary>
64
+
internalbyte[]InstantiationData;
65
+
60
66
/// <summary>
61
67
/// All <see cref="NetworkTransform"/> component instances associated with a <see cref="NetworkObject"/> component instance.
62
68
/// </summary>
@@ -2837,6 +2843,12 @@ public bool SpawnWithObservers
2837
2843
set=>ByteUtility.SetBit(refm_BitField,10,value);
2838
2844
}
2839
2845
2846
+
publicboolHasInstantiationData
2847
+
{
2848
+
get=>ByteUtility.GetBit(m_BitField,11);
2849
+
set=>ByteUtility.SetBit(refm_BitField,11,value);
2850
+
}
2851
+
2840
2852
// When handling the initial synchronization of NetworkObjects,
2841
2853
// this will be populated with the known observers.
2842
2854
publiculong[]Observers;
@@ -2925,6 +2937,12 @@ public void Serialize(FastBufferWriter writer)
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/Runtime/Spawning/NetworkPrefabHandler.cs
+94-12Lines changed: 94 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,10 @@ public interface INetworkPrefabInstanceHandler
21
21
/// Note on Pooling: If you are using a NetworkObject pool, don't forget to make the NetworkObject active
22
22
/// via the <see cref="GameObject.SetActive(bool)"/> method.
23
23
/// </summary>
24
+
/// <remarks>
25
+
/// If you need to pass custom data at instantiation time (e.g., selecting a variant, setting initialization parameters, or choosing a pre-instantiated object),
/// Links the custom prefab instance's GlobalNetworkObjectId to the original prefab asset's GlobalNetworkObjectId. (Needed for HandleNetworkPrefabDestroy)
62
72
/// [PrefabInstance][PrefabAsset]
@@ -98,12 +108,44 @@ public bool AddHandler(uint globalObjectIdHash, INetworkPrefabInstanceHandler in
0 commit comments