private void CleanUp() { foreach (RenderTexture rt in ReflRenderTextures.Values) { if (rt == null) { continue; } rt.Release(); PUtilities.DestroyObject(rt); } foreach (Camera cam in ReflCameras.Values) { if (cam == null) { continue; } PUtilities.DestroyGameobject(cam.gameObject); } if (mesh != null) { PUtilities.DestroyObject(mesh); } if (spline != null) { spline.Dispose(); } }
public void Dispose() { if (mesh != null) { PUtilities.DestroyObject(mesh); } }
public static void FillTexture(RenderTexture rt, Color c) { Texture2D tex = new Texture2D(1, 1, TextureFormat.ARGB32, false); tex.SetPixel(0, 0, c); tex.Apply(); CopyToRT(tex, rt); PUtilities.DestroyObject(tex); }
public static void CopyTexture(Texture2D src, Texture2D des) { RenderTexture rt = new RenderTexture(des.width, des.height, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Default); CopyToRT(src, rt); CopyFromRT(des, rt); rt.Release(); PUtilities.DestroyObject(rt); }
private RenderTexture GetReflectionRt(Camera cam) { if (!ReflRenderTextures.ContainsKey(cam)) { ReflRenderTextures.Add(cam, null); } int resolution = 128; if (Profile != null) { resolution = Profile.ReflectionTextureResolution; } RenderTexture rt = ReflRenderTextures[cam]; if (rt == null) { rt = new RenderTexture(resolution, resolution, 16, RenderTextureFormat.ARGB32); } if (rt.width != resolution || rt.height != resolution) { Camera reflCam; if (ReflCameras.TryGetValue(cam, out reflCam)) { reflCam.targetTexture = null; } rt.Release(); PUtilities.DestroyObject(rt); rt = new RenderTexture(resolution, resolution, 16, RenderTextureFormat.ARGB32); } rt.name = string.Format("~ReflectionRt_{0}_{1}", cam.name, resolution); ReflRenderTextures[cam] = rt; if (cam.stereoEnabled) { rt.Release(); } return(rt); }