void CheckInit() { var width = targetCamera.pixelWidth >> lod; var height = targetCamera.pixelHeight >> lod; if (_distTex == null || _distTex.width != width || _distTex.height != height) { Release(); _distTex = new RenderTexture(width, height, 0, RenderTextureFormat.RGFloat, RenderTextureReadWrite.Linear); _distTex.filterMode = FilterMode.Bilinear; _distTex.wrapMode = TextureWrapMode.Clamp; _distTex.antiAliasing = (QualitySettings.antiAliasing == 0 ? 1 : QualitySettings.antiAliasing); _normTex = new RenderTexture(width, height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear); _normTex.filterMode = FilterMode.Bilinear; _normTex.wrapMode = TextureWrapMode.Clamp; _normTex.antiAliasing = _distTex.antiAliasing; _viewProps.SetTexture(ShaderConsts.PROP_NORM_TEXTURE, _normTex); _normTex2D = new Texture2D(width, height, TextureFormat.ARGB32, false, true); } if (_points == null) { _points = new PointService(pointCapacity); } }
void Release() { if (_distTex != null) { Destroy(_distTex); _distTex = null; } if (_normTex != null) { Destroy(_normTex); _normTex = null; } if (_normTex2D != null) { Destroy(_normTex2D); _normTex2D = null; } if (_points != null) { _points.Dispose(); _points = null; } }