Example #1
0
        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);
        }