109 lines
1.6 KiB
C#
109 lines
1.6 KiB
C#
using UnityEngine;
|
|
|
|
namespace DebuggingEssentials
|
|
{
|
|
public static class GraphicsHelper
|
|
{
|
|
public static void Dispose(ref RenderTexture rt)
|
|
{
|
|
if (!(rt == null))
|
|
{
|
|
rt.Release();
|
|
if (Application.isPlaying)
|
|
{
|
|
Object.Destroy(rt);
|
|
}
|
|
else
|
|
{
|
|
Object.DestroyImmediate(rt);
|
|
}
|
|
rt = null;
|
|
}
|
|
}
|
|
|
|
public static void Dispose(ref RenderTexture[] rts)
|
|
{
|
|
if (rts != null)
|
|
{
|
|
for (int i = 0; i < rts.Length; i++)
|
|
{
|
|
Dispose(ref rts[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void Dispose(ref Texture2D tex)
|
|
{
|
|
if (!(tex == null))
|
|
{
|
|
if (Application.isPlaying)
|
|
{
|
|
Object.Destroy(tex);
|
|
}
|
|
else
|
|
{
|
|
Object.DestroyImmediate(tex);
|
|
}
|
|
tex = null;
|
|
}
|
|
}
|
|
|
|
public static void Dispose(ref Texture3D tex)
|
|
{
|
|
if (!(tex == null))
|
|
{
|
|
if (Application.isPlaying)
|
|
{
|
|
Object.Destroy(tex);
|
|
}
|
|
else
|
|
{
|
|
Object.DestroyImmediate(tex);
|
|
}
|
|
tex = null;
|
|
}
|
|
}
|
|
|
|
public static void Dispose(ref Texture2D[] textures)
|
|
{
|
|
if (textures != null)
|
|
{
|
|
for (int i = 0; i < textures.Length; i++)
|
|
{
|
|
Dispose(ref textures[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void DisposeLightmaps()
|
|
{
|
|
LightmapSettings.lightmaps = null;
|
|
}
|
|
|
|
public static void Dispose(ref ComputeBuffer computeBuffer)
|
|
{
|
|
if (computeBuffer != null)
|
|
{
|
|
computeBuffer.Dispose();
|
|
computeBuffer = null;
|
|
}
|
|
}
|
|
|
|
public static void Dispose(ref Mesh mesh)
|
|
{
|
|
if (!(mesh == null))
|
|
{
|
|
if (Application.isPlaying)
|
|
{
|
|
Object.Destroy(mesh);
|
|
}
|
|
else
|
|
{
|
|
Object.DestroyImmediate(mesh);
|
|
}
|
|
mesh = null;
|
|
}
|
|
}
|
|
}
|
|
}
|