初始化

This commit is contained in:
2026-06-05 22:12:05 +08:00
commit d7146f87ac
1999 changed files with 221608 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using Object = UnityEngine.Object;
namespace EPOOutline
{
public class MeshPool : IDisposable
{
private Queue<Mesh> freeMeshes = new Queue<Mesh>();
private List<Mesh> allMeshes = new List<Mesh>();
public Mesh AllocateMesh()
{
while (freeMeshes.Count > 0 && freeMeshes.Peek() == null)
freeMeshes.Dequeue();
if (freeMeshes.Count == 0)
{
var mesh = new Mesh();
mesh.MarkDynamic();
allMeshes.Add(mesh);
freeMeshes.Enqueue(mesh);
}
return freeMeshes.Dequeue();
}
public void ReleaseAllMeshes()
{
freeMeshes.Clear();
foreach (var mesh in allMeshes)
freeMeshes.Enqueue(mesh);
}
public void Dispose()
{
foreach (var mesh in allMeshes)
Object.DestroyImmediate(mesh);
allMeshes.Clear();
freeMeshes.Clear();
}
}
}