Skip to content

Commit 7d04852

Browse files
harayuu9EmandM
authored andcommitted
add asNativeArray NetworkList
1 parent bea303f commit 7d04852

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
@@ -631,6 +631,18 @@ public T this[int index]
631631
}
632632
}
633633

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

0 commit comments

Comments
 (0)