Initial commit: AIGame Unity client with URP, HybridCLR, YooAsset and tooling.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace IlInterpreter.Interpreter
|
||||
{
|
||||
|
||||
// Default frame allocator used outside Unity (and anywhere a host doesn't inject its own).
|
||||
// Marshal.AllocHGlobal is platform-neutral and AOT/IL2CPP-safe, and keeps the engine free of
|
||||
// any Unity.Collections dependency. Returns 8-byte-aligned memory on all supported runtimes.
|
||||
sealed unsafe class MarshalFrameAllocator : IFrameAllocator
|
||||
{
|
||||
public static readonly MarshalFrameAllocator Instance = new();
|
||||
|
||||
public void* Alloc(int byteCount) => (void*)Marshal.AllocHGlobal(byteCount);
|
||||
|
||||
public void Free(void* ptr)
|
||||
{
|
||||
if (ptr != null) Marshal.FreeHGlobal((nint)ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user