You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
794 B

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace UltraCombos.Utility
{
public sealed class NativeBufferPool : Singleton<NativeBufferPool>
{
private NativeBufferPool() { }
Dictionary<System.IntPtr, System.IntPtr> references = new Dictionary<System.IntPtr, System.IntPtr>();
public System.IntPtr GetReference(System.IntPtr bufferHandle)
{
if (references.ContainsKey(bufferHandle) == false)
references.Add(bufferHandle, Buffer.Create(bufferHandle));
return references[bufferHandle];
}
private void OnDestroy()
{
foreach (var buf in references.Values)
{
Buffer.Release(buf);
}
}
}
}