Commit 5f9463a
feat: AttachableBehaviour and ComponentController (#3518)
## Depends on
This PR depends upon the fix for the `SendTo.NotMe` fix in #3551.
## AttachableBehaviour and Support Components
The purpose of this PR (feat) is to address the complexity of "picking
up" or "dropping" an item in the world which can become complex when
using the traditional `NetworkObject` parenting pattern. In this PR
there are three primary components added to help reduce this complexity:
- `AttachableBehaviour`: Provides "out of the box" support for attaching
(i.e. parenting) a nested child `GameObject` that includes an
`AttachableBehaviour` component to another nested child `GameObject`
with an `AttachableNode` component that is associated with a different
`NetworkObject`.
- `AttachableNode`: This component is required by the
`AttachableBehaviour` component in order to be able to attach (i.e.
parent) to another GameObject without having to parent the entire
`NetworkObject` component the `AttachableBehaviour` component is
associated with.
- `ComponentController`: This component provides users the ability to
synchronize the enabling or disabling of any `Object` derived component
that has an `enabled` property.
_This PR also incorporates a new "Helpers" subfolder under the NGO
components folder where additional helper components will live._
## Documentation Update
## New Documentation
[AttachableBehaviour](https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/blob/feat/attachable-networkbehaviour-and-object-controller/com.unity.netcode.gameobjects/Documentation~/components/Helpers/attachablebehaviour.md)
### Network Components Section Update
<img width="957" height="589" alt="image"
src="https://github.com/user-attachments/assets/48e9edaf-cf8d-4a61-b0b9-c0369bb8f26f"
/>
### New Foundational Components Section
<img width="1145" height="831" alt="image"
src="https://github.com/user-attachments/assets/f3dc71b4-cd07-4884-a5a6-fc7c78e9e24c"
/>
### New Helper Components Section
<img width="1015" height="537" alt="image"
src="https://github.com/user-attachments/assets/407636b8-9085-4b80-8bb4-d55b18512ce1"
/>
## NetworkBehaviour.OnNetworkPreDespawn
Added another virtual method to `NetworkBehaviour`,
`OnNetworkPreDespawn`, that is invoked before running through the
despawn sequence for the `NetworkObject` and all `NetworkBehaviour`
children of the `NetworkObject` being despawned. This provides an
opportunity to do any kind of cleanup up or last micro-second state
updates prior to despawning.
<!-- Add short version of the JIRA ticket to the PR title (e.g. "feat:
new shiny feature [MTT-123]") -->
## Changelog
- Added: `AttachableBehaviour` helper component to provide an alternate
approach to parenting items without using the `NetworkObject` parenting.
- Added : `AttachableNode` helper component that is used by
`AttachableBehaviour` as the target node for parenting.
- Added: `ComponentController` helper component that can be used to
synchronize the enabling and disabling of components and can be used in
conjunction with `AttachableBehaviour`.
- Added: `NetworkBehaviour.OnNetworkPreDespawn` that is invoked before
running through the despawn sequence for the `NetworkObject` and all
`NetworkBehaviour` children of the `NetworkObject` being despawned.
<!-- Uncomment and mark items off with a * if this PR deprecates any
API:
### Deprecated API
- [ ] An `[Obsolete]` attribute was added along with a `(RemovedAfter
yyyy-mm-dd)` entry.
- [ ] An [api updater] was added.
- [ ] Deprecation of the API is explained in the CHANGELOG.
- [ ] The users can understand why this API was removed and what they
should use instead.
-->
## Documentation
[//]: # (
This section is REQUIRED and should mention what documentation changes
were following the changes in this PR.
We should always evaluate if the changes in this PR require any
documentation changes.
)
- Includes documentation updates:
- Added new documentation section.
- Refactored network components section.
- Fixed some image links.
## Testing & QA
[//]: # (
This section is REQUIRED and should describe how the changes were tested
and how should they be tested when Playtesting for the release.
It can range from "edge case covered by unit tests" to "manual testing
required and new sample was added".
Expectation is that PR creator does some manual testing and provides a
summary of it here.)
### Functional Testing
[//]: # (If checked, List manual tests that have been performed.)
_Manual testing :_
- [X] `Manual testing done`
- Asteroids `AttachableBehaviour` manual test
[PR-42](https://github.cds.internal.unity3d.com/unity/Asteroids-CMB-NGO-Sample/pull/42)
_Automated tests:_
- [ ] `Covered by existing automated tests`
- [X] `Covered by new automated tests`
_Does the change require QA team to:_
- [ ] `Review automated tests`?
- [ ] `Execute manual tests`?
If any boxes above are checked, please add QA as a PR reviewer.
## Backport
This is a v2.x only feature.
<!-- If this is a backport:
- Add the following to the PR title: "\[Backport\] ..." .
- Link to the original PR.
If this needs a backport - state this here
If a backport is not needed please provide the reason why.
If the "Backports" section is not present it will lead to a CI test
failure.
-->
---------
Co-authored-by: Emma <[email protected]>
Co-authored-by: Amy Reeve <[email protected]>
Co-authored-by: Unity Netcode CI <[email protected]>1 parent 42002f9 commit 5f9463a
File tree
101 files changed
+3562
-835
lines changed- Examples
- CharacterControllerMovingBodies
- OverridingScenesAndPrefabs
- com.unity.netcode.gameobjects
- Documentation~
- advanced-topics
- message-system
- network-update-loop-system
- serialization
- basics
- scenemanagement
- components
- core
- helper
- images
- NetworkBehaviour
- attachable
- learn
- relay
- samples
- bitesize
- bossroom
- troubleshooting
- tutorials
- testing
- Editor/CodeGen
- Runtime
- Components
- Helpers
- Core
- Spawning
- Samples~/Bootstrap/Scripts
- Tests/Runtime
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
101 files changed
+3562
-835
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | | - | |
| 75 | + | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
0 commit comments