Search Unity

Changing Render Texture Camera Output through C# Script

Discussion in 'Scripting' started by Volt777, Mar 2, 2019.

  1. Volt777

    Volt777

    Joined:
    Aug 6, 2018
    Posts:
    16
    I am making a fnaf fan game and I am wondering if it is possible to change a render texture through c# script. I have seen this been done before, but all I have seen have used some sort of add-on/plugin or 3D party software.

    Please leave information and comments below.
     
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    Yes, you can use a RenderTexture as if it was any sort of texture. What are you trying to do exactly?

    The easiest route is probably to draw the RenderTexture stretched to the screen via a UI RawImage and then you can apply any sort of material/shader you want to it.
     
  3. minerphips

    minerphips

    Joined:
    May 13, 2018
    Posts:
    1
    Maybe the following Code can help any of you :)
    Code (CSharp):
    1. public RenderTexture desiredTexture;
    2.  
    3. private void OnRenderImage(RenderTexture source, RenderTexture destination)
    4.     {
    5.         Graphics.Blit(desiredTexture, destination);
    6.     }