WuhuIslandTesting/Library/PackageCache/com.stresslevelzero.static-batching@1.0.1/runtime/unsafe/NativeArraySubArray.cs
2025-01-07 02:06:59 +01:00

27 lines
816 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using UnityEngine;
namespace SLZ.CustomStaticBatching
{
public static unsafe class NativeArraySubArray
{
public static unsafe NativeArray<T2> GetSubArrayAlias<T, T2>(NativeArray<T> array, int start, int length)
where T : unmanaged
where T2 : unmanaged
{
void* dataPointer = ((byte*)array.GetUnsafePtr()) + start * sizeof(T);
NativeArray<T2> outp = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray<T2>(dataPointer, length, Allocator.None);
#if ENABLE_UNITY_COLLECTIONS_CHECKS
NativeArrayUnsafeUtility.SetAtomicSafetyHandle(ref outp, AtomicSafetyHandle.GetTempMemoryHandle());
#endif
return outp;
}
}
}