Commit f4b6cd4
Continues: #3562 from @harayuu9
This PR exposes the contents of a `NetworkList<T>` as a **read‑only
`NativeArray<T>`**.
It addresses the recurring need to interoperate efficiently with
Burst‑compiled or `IJob`‑based code without paying the cost of
element‑wise copies or allocations.
The accessor simply forwards `m_List.AsReadOnly()`, preserving
zero‑allocation semantics while respecting `NativeArray`’s lifetime
constraints (call‑site must guarantee the list is not mutated or
disposed).
No behavioural changes are introduced—only a pure additive surface‑area
expansion.
## Changelog
- Added: `NetworkList<T>.AsNativeArray()` to return the list contents as
a `NativeArray<T>.ReadOnly`.
## Testing and Documentation
- No tests have been added.
- Includes documentation for the newly added public API function.
## Backport
This adds a new API surface area and so no backport is required.
---------
Co-authored-by: Yuto Harada <yuto.harada@polyscape.io>
1 parent 1bcb377 commit f4b6cd4
File tree
2 files changed
+19
-0
lines changed- com.unity.netcode.gameobjects
- Runtime/NetworkVariable/Collections
2 files changed
+19
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
631 | 631 | | |
632 | 632 | | |
633 | 633 | | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
634 | 652 | | |
635 | 653 | | |
636 | 654 | | |
| |||
0 commit comments