Class NativeCollectionsExtensions
- Namespace
- RisingV.Shared.Extensions
- Assembly
- RisingV.Shared.dll
Provides extension methods for working with Unity's Native Collections.
public static class NativeCollectionsExtensions
- Inheritance
-
NativeCollectionsExtensions
- Inherited Members
Methods
IsEmpty<T>(NativeArray<T>)
Checks if a NativeArray is empty.
public static bool IsEmpty<T>(this NativeArray<T> nativeArray) where T : unmanaged
Parameters
nativeArray
NativeArray<T>The NativeArray to check.
Returns
- bool
True if the NativeArray is empty, otherwise false.
Type Parameters
T
The type of elements in the NativeArray, must be unmanaged.
IsNullOrEmpty<T>(NativeArray<T>?)
Checks if a NativeArray is null or empty.
public static bool IsNullOrEmpty<T>(this NativeArray<T>? nativeArray) where T : unmanaged
Parameters
nativeArray
NativeArray<T>?The NativeArray to check.
Returns
- bool
True if the NativeArray is null or empty, otherwise false.
Type Parameters
T
The type of elements in the NativeArray, must be unmanaged.
PrintItems<T>(NativeArray<T>, Logger, LogLevel)
Prints each item in a NativeArray to the specified logger at the specified log level.
public static void PrintItems<T>(this NativeArray<T> array, Logger logger, LogLevel logLevel = LogLevel.Debug) where T : unmanaged
Parameters
array
NativeArray<T>The NativeArray whose items will be printed.
logger
LoggerThe logger to which the items will be printed.
logLevel
LogLevelThe log level at which to print the items.
Type Parameters
T
The type of elements in the NativeArray, must be unmanaged.
PrintItems<TValue>(NativeList<TValue>, Logger, LogLevel)
Prints each item in a NativeList to the specified logger at the specified log level.
public static void PrintItems<TValue>(this NativeList<TValue> list, Logger logger, LogLevel logLevel = LogLevel.Debug) where TValue : unmanaged
Parameters
list
NativeList<TValue>The NativeList whose items will be printed.
logger
LoggerThe logger to which the items will be printed.
logLevel
LogLevelThe log level at which to print the items.
Type Parameters
TValue
The type of elements in the NativeList, must be unmanaged.
PrintItems<TKey, TValue>(NativeHashMap<TKey, TValue>, Logger, LogLevel)
Prints each key-value pair in a NativeHashMap to the specified logger at the specified log level.
public static void PrintItems<TKey, TValue>(this NativeHashMap<TKey, TValue> map, Logger logger, LogLevel logLevel = LogLevel.Debug) where TKey : unmanaged
Parameters
map
NativeHashMap<TKey, TValue>The NativeHashMap whose items will be printed.
logger
LoggerThe logger to which the items will be printed.
logLevel
LogLevelThe log level at which to print the items.
Type Parameters
TKey
The type of keys in the NativeHashMap, must be unmanaged.
TValue
The type of values in the NativeHashMap, must be unmanaged.
ToList<T>(NativeList<T>)
Converts a NativeArray to a List.
public static List<T> ToList<T>(this NativeList<T> nativeList) where T : unmanaged
Parameters
nativeList
NativeList<T>The NativeArray to convert.
Returns
- List<T>
A List containing the elements from the NativeArray.
Type Parameters
T
The type of elements in the NativeArray, must be unmanaged.
ToStringBy<T>(NativeArray<T>, Func<T, string>, string)
Converts a NativeArray to a string representation using a specified function for each element.
public static string ToStringBy<T>(this NativeArray<T> array, Func<T, string> func, string separator = ", ") where T : unmanaged
Parameters
array
NativeArray<T>The NativeArray to convert.
func
Func<T, string>The function to apply to each element of the NativeArray to convert it to a string.
separator
stringThe separator to use between elements in the resulting string.
Returns
- string
A string representation of the NativeArray, with each element converted using the specified function and separated by the specified separator.
Type Parameters
T
The type of elements in the NativeArray, must be unmanaged.