Skip to content

Commit 30b0cfb

Browse files
committed
add asNativeArray NetworkList
1 parent 3da80e7 commit 30b0cfb

File tree

1 file changed

+12
-0
lines changed
  • com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections

1 file changed

+12
-0
lines changed

com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,18 @@ public T this[int index]
632632
}
633633
}
634634

635+
/// <summary>
636+
/// Returns the contents of the NetworkList as a read-only NativeArray.
637+
/// </summary>
638+
/// <remarks>
639+
/// This method returns the list contents as a NativeArray.ReadOnly. Be careful with the lifetime of the NativeArray.
640+
/// </remarks>
641+
/// <returns>A read-only NativeArray of the list contents.</returns>
642+
public NativeArray<T>.ReadOnly AsNativeArray()
643+
{
644+
return m_List.AsReadOnly();
645+
}
646+
635647
private void HandleAddListEvent(NetworkListEvent<T> listEvent)
636648
{
637649
m_DirtyEvents.Add(listEvent);

0 commit comments

Comments
 (0)