-
Notifications
You must be signed in to change notification settings - Fork 463
feat: Add ability to send instantiation data to a prefab handler #3497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 60 commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
3ff9326
feat: Network Object Instantiation Payload
Extrys 7f395ba
Merge branch 'Unity-Technologies:develop-2.0.0' into develop-2.0.0
Extrys f0d49aa
insight on INetworkInstantiationPayloadSynchronizer in the INetworkPr…
Extrys 3f34e83
cleaning diff
Extrys 47680f5
Some fixes for object instantiated in the server without handler
Extrys b8765a2
Merge branch 'Unity-Technologies:develop-2.0.0' into develop-2.0.0
Extrys de9fc05
Simplified approach that reuses createObjectMesage bufferSerializer
Extrys 6419ad0
commented non generic serialization methods
Extrys 1d746fe
Merge branch 'feat/InstantiationPayload' into develop-2.0.0
Extrys 4005c50
Cleaning diff
Extrys a103e49
Cleaning diff
Extrys 43e8ff4
Review Changes
Extrys 0fab0a6
Some more renamigs for making it more closer to unity's naming
Extrys 36a041c
Merge branch 'develop-2.0.0' into develop-2.0.0
Extrys fd787e8
Merge branch 'develop-2.0.0' into develop-2.0.0
Extrys 96b7af6
Added buffer safety and Tests
Extrys e49cb63
Merge remote-tracking branch 'origin/develop-2.0.0' into develop-2.0.0
Extrys 89eb5c4
Log text change for more clarity
Extrys adead9d
Renamed HasInstantiationPayload to HasInstantiationData to mantain na…
Extrys e4481b2
CHANGELOG.md entry added
Extrys 3522fc0
Merge branch 'Unity-Technologies:develop-2.0.0' into develop-2.0.0
Extrys 6757e63
Solved late-join problems
Extrys a5670e3
cleaning diff
Extrys 426d82c
Updated comment
Extrys 6899764
Added more Buffer/Synchronization safety changes
Extrys c1d6503
Improves handler lookup performance
Extrys 096c85c
New stateless approach working flawless
Extrys 7f6c9c7
Test updated
Extrys 89dd4c0
Test refactor and included late joining test
Extrys b992b7c
clean diff
Extrys 1f27a68
Changelog updated
Extrys 5b68637
Adds comment for data handling workaround
Extrys d42bf95
Cleaning diff, fixed comment accidentally using a chinese version of …
Extrys 4c7f63d
New requirements fullfilled
Extrys 2b6befd
removed yet unused method
Extrys 3dea6aa
extending the interface to directly allow different injection patterns
Extrys 015e384
Merge branch 'develop-2.0.0' into develop-2.0.0
Extrys 536642b
Pure stateless, non generic approach for sending data through fastBuf…
Extrys fa774e7
Merge branch 'develop-2.0.0' into develop-2.0.0
Extrys 0d62ea4
renamings from Inject to Set
Extrys 3fad66c
Inlined functions and removed terniary call
Extrys 81d574a
Changed instantiation data throw by an error log
Extrys 36ec35f
Abstract class approach, removed wrapper
Extrys 7326a83
Removed the BufferSerializer From the GetInstantiationDataReader method
Extrys e8a661c
Using Approach A (unsafe block) to avoid allocations for FastBufferRe…
Extrys f47f3d4
Most review comments addressed
Extrys 6b3963f
Renamed Interface in the Changelog
Extrys fc43642
Update formatting and use NetcodeIntegrationTest for test class
EmandM 729f4d6
fixed late join bug
Extrys fea9d7d
Merge branch 'develop-2.0.0' into develop-2.0.0
Extrys 900c7ee
Using BytePacker utilities to optimize the size of the serialized int…
Extrys 886697e
Updated comment to match new interface name
Extrys 4586a6e
Merge branch 'develop-2.0.0' into develop-2.0.0
Extrys a34ec5a
Merge remote-tracking branch 'extrys/develop-2.0.0' into feat/sync-in…
EmandM 0d51492
Rework serialization to work with distributed authority
EmandM 050e150
Merge branch 'develop-2.0.0' of https://github.com/Unity-Technologies…
EmandM a364c99
Add missing code doc
EmandM 1b37f13
Add typeparam
EmandM e944ede
Add missing documentation to NetworkPrefabInstanceHandlerWithData
EmandM efa756c
Handle null response from Instatiate call with data
EmandM 8ba2043
Add PrefabHandler shutdown
EmandM 4f79aa2
Merge branch 'develop-2.0.0' into feat/sync-instantiation-data
NoelStephensUnity 19b07a3
Merge branch 'develop-2.0.0' of https://github.com/Unity-Technologies…
EmandM 61474f3
Merge branch 'feat/sync-instantiation-data' of https://github.com/Uni…
EmandM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
com.unity.netcode.gameobjects/Runtime/Spawning/INetworkPrefabInstanceHandler.cs
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like that we moved this into its own file. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| using System.Collections.Generic; | ||
| using UnityEngine; | ||
|
|
||
| namespace Unity.Netcode | ||
| { | ||
| /// <summary> | ||
| /// Interface for customizing, overriding, spawning, and destroying Network Prefabs | ||
| /// Used by <see cref="NetworkPrefabHandler"/> | ||
| /// </summary> | ||
| public interface INetworkPrefabInstanceHandler | ||
| { | ||
| /// <summary> | ||
| /// Client Side Only | ||
| /// Once an implementation is registered with the <see cref="NetworkPrefabHandler"/>, this method will be called every time | ||
| /// a Network Prefab associated <see cref="NetworkObject"/> is spawned on clients | ||
| /// | ||
| /// Note On Hosts: Use the <see cref="NetworkPrefabHandler.RegisterHostGlobalObjectIdHashValues(GameObject, List{T})"/> | ||
| /// method to register all targeted NetworkPrefab overrides manually since the host will be acting as both a server and client. | ||
| /// | ||
| /// Note on Pooling: If you are using a NetworkObject pool, don't forget to make the NetworkObject active | ||
| /// via the <see cref="GameObject.SetActive(bool)"/> method. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// If you need to pass custom data at instantiation time (e.g., selecting a variant, setting initialization parameters, or choosing a pre-instantiated object), | ||
| /// implement <see cref="NetworkPrefabInstanceHandlerWithData{T}"/> instead. | ||
| /// </remarks> | ||
| /// <param name="ownerClientId">the owner for the <see cref="NetworkObject"/> to be instantiated</param> | ||
| /// <param name="position">the initial/default position for the <see cref="NetworkObject"/> to be instantiated</param> | ||
| /// <param name="rotation">the initial/default rotation for the <see cref="NetworkObject"/> to be instantiated</param> | ||
| /// <returns>The instantiated NetworkObject instance. Returns null if instantiation fails.</returns> | ||
| public NetworkObject Instantiate(ulong ownerClientId, Vector3 position, Quaternion rotation); | ||
|
|
||
| /// <summary> | ||
| /// Invoked on Client and Server | ||
| /// Once an implementation is registered with the <see cref="NetworkPrefabHandler"/>, this method will be called when | ||
| /// a Network Prefab associated <see cref="NetworkObject"/> is: | ||
| /// | ||
| /// Server Side: destroyed or despawned with the destroy parameter equal to true | ||
| /// If <see cref="NetworkObject.Despawn(bool)"/> is invoked with the default destroy parameter (i.e. false) then this method will NOT be invoked! | ||
| /// | ||
| /// Client Side: destroyed when the client receives a destroy object message from the server or host. | ||
| /// | ||
| /// Note on Pooling: When this method is invoked, you do not need to destroy the NetworkObject as long as you want your pool to persist. | ||
| /// The most common approach is to make the <see cref="NetworkObject"/> inactive by calling <see cref="GameObject.SetActive(bool)"/>. | ||
| /// </summary> | ||
| /// <param name="networkObject">The <see cref="NetworkObject"/> being destroyed</param> | ||
| public void Destroy(NetworkObject networkObject); | ||
| } | ||
| } |
3 changes: 3 additions & 0 deletions
3
com.unity.netcode.gameobjects/Runtime/Spawning/INetworkPrefabInstanceHandler.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.