private void InitPreview(Rect r, bool hdr)
{
this.m_TargetRect = r;
float scaleFactor = this.GetScaleFactor(r.width, r.height);
int width = (int) (r.width * scaleFactor);
int height = (int) (r.height * scaleFactor);
if (((this.m_RenderTexture == null) || (this.m_RenderTexture.width != width)) || (this.m_RenderTexture.height != height))
{
if (this.m_RenderTexture != null)
{
Object.DestroyImmediate(this.m_RenderTexture);
this.m_RenderTexture = null;
}
this.m_RenderTexture = new RenderTexture(width, height, 0x10, !hdr ? RenderTextureFormat.ARGB32 : RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Default);
this.m_RenderTexture.hideFlags = HideFlags.HideAndDontSave;
this.m_Camera.targetTexture = this.m_RenderTexture;
}
float num4 = (this.m_RenderTexture.width > 0) ? Mathf.Max((float) 1f, (float) (((float) this.m_RenderTexture.height) / ((float) this.m_RenderTexture.width))) : 1f;
this.m_Camera.fieldOfView = (Mathf.Atan(num4 * Mathf.Tan((this.m_CameraFieldOfView * 0.5f) * 0.01745329f)) * 57.29578f) * 2f;
this.m_SavedState = new SavedRenderTargetState();
EditorGUIUtility.SetRenderTextureNoViewport(this.m_RenderTexture);
GL.LoadOrtho();
GL.LoadPixelMatrix(0f, (float) this.m_RenderTexture.width, (float) this.m_RenderTexture.height, 0f);
ShaderUtil.rawViewportRect = new Rect(0f, 0f, (float) this.m_RenderTexture.width, (float) this.m_RenderTexture.height);
ShaderUtil.rawScissorRect = new Rect(0f, 0f, (float) this.m_RenderTexture.width, (float) this.m_RenderTexture.height);
GL.Clear(true, true, new Color(0f, 0f, 0f, 0f));
}
}