WuhuIslandTesting/Library/PackageCache/com.stresslevelzero.static-batching@1.0.1/runtime/unsafe/SpanSortExt.cs

21 lines
556 B
C#
Raw Normal View History

2025-01-07 02:06:59 +01:00
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using UnityEngine;
namespace SLZ.CustomStaticBatching
{
public unsafe static class SpanSortExt
{
public static void Sort<T>(ref Span<T> span) where T : unmanaged, IComparable<T>
{
fixed (T* pData = &span.GetPinnableReference())
{
NativeArray<T> nativeCast = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray<T>((void*)pData, span.Length, Allocator.None);
nativeCast.Sort();
}
}
}
}