- Home /
Assign render texture to material
How do I assign a render texture to the material, that is used to show the render texture in runtime?
I have a render texture and a metarial assigned to a gameobject, and the render texture shows up there. But how is it connected to each other?
Answer by cakeslice · Dec 24, 2016 at 11:25 AM
A RenderTexture is just like any other texture so you can do this:
public Material m;
public RenderTexture r;
m.mainTexture = r;
I just went through all my scripts, I never assigned the texture to a material that way... odd that it works but is not reproduceable....
Beside that, it isn't working (see forum thread about it): https://forum.unity3d.com/threads/material-with-render-texture-will-not-show-up.447841/
Your answer

Follow this Question
Related Questions
Set dynamic generated alpha mask on shader at runtime 0 Answers
Converting a RenderTexture to a Texture2D for use in a shader 2 Answers
Material doesn't have a color property '_Color' 4 Answers
Need help with creating dynamic textures. 1 Answer
unwanted pale shadow like,at the edje of gameobject in high speed 0 Answers