void DrawRenderTexture(int index) { RenderTexture.active = this.RenderTexture; Graphics.SetRenderTarget(this.RenderTexture); MeshAnimationEditor.DrawPreviewNow(this.target as MeshAnimation, this.RenderTexture.width, this.RenderTexture.height, index); RenderTexture.active = null; }
override public Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height) { // get temporary render texture RenderTexture renderTexture = RenderTexture.GetTemporary( width, height, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default, 1 ); // set the active render texture RenderTexture.active = renderTexture; // draw the preview Graphics.SetRenderTarget(renderTexture); MeshAnimationEditor.DrawPreviewNow(this.target as MeshAnimation, width, height, 0); // create the texture Texture2D texture = new Texture2D(width, height, TextureFormat.ARGB32, false); texture.ReadPixels(new Rect(0, 0, width, height), 0, 0, false); texture.Apply(); // release the render texture RenderTexture.active = null; RenderTexture.ReleaseTemporary(renderTexture); // return the texture return(texture); }