private Texture2D CreateTemporaryDuplicate(Texture2D original, int width, int height)
{
if (!ShaderUtil.hardwareSupportsRectRenderTexture || (original == null))
{
return null;
}
EditorUtility.SetTemporarilyAllowIndieRenderTexture(true);
RenderTexture active = RenderTexture.active;
bool flag = !TextureUtil.GetLinearSampled(original);
RenderTexture dest = RenderTexture.GetTemporary(width, height, 0, RenderTextureFormat.Default, !flag ? RenderTextureReadWrite.Linear : RenderTextureReadWrite.sRGB);
GL.sRGBWrite = flag && (QualitySettings.activeColorSpace == ColorSpace.Linear);
Graphics.Blit(original, dest);
GL.sRGBWrite = false;
RenderTexture.active = dest;
bool flag2 = (width >= SystemInfo.maxTextureSize) || (height >= SystemInfo.maxTextureSize);
Texture2D textured = new Texture2D(width, height, TextureFormat.ARGB32, (original.mipmapCount > 1) || flag2);
textured.ReadPixels(new Rect(0f, 0f, (float) width, (float) height), 0, 0);
textured.Apply();
RenderTexture.ReleaseTemporary(dest);
EditorGUIUtility.SetRenderTextureNoViewport(active);
EditorUtility.SetTemporarilyAllowIndieRenderTexture(false);
textured.alphaIsTransparency = original.alphaIsTransparency;
return textured;
}