Gui.window with render texture

I’m trying to display the render texture in a Gui Window. I have the render texture set up from a camera and created a material for it. Now I want to display inside the gui window. I tried placing the material inside the Resource folder and use Resources.Load to load it as a texture, but I get a “cannot cast source type to destination type error”. Is there an easier way to do this?

var tex:Texture2D = Resources.Load(“Resources/Rend”);

function OnGUI() {
GUI.Window(0,Rect(200,129,100,100),funcwin,“window”);
}

function funcwin(windowID:int)
{
GUI.DrawTexture(Rect(0, 0, 100, 100), tex);
}

where you put the material is irrelevant as gui does not use materials at all.

your problem here is that you declare it as var tex:Texture2D instead of var tex : Texture

cause rendertexture is incompatible to texture2D.

texture2d and rendertexture though both expand from texture

Is there a script where I can use the “render texture” in the gui.drawtexture function?

It works now. Putting render texture directly under resources folder and load it in as Texture not Texture2D. Thanks Dreamora.