Description: RenderTexture.DiscardContents is a method that clears the contents of the RenderTexture. This is useful when you want to clear the RenderTexture before using it again.
Code Examples:
//Create a RenderTexture RenderTexture tex = new RenderTexture(1024, 1024, 0);
//Clear the contents of the RenderTexture tex.DiscardContents();
//Use the RenderTexture in a camera Camera cam = GetComponent(); cam.targetTexture = tex;
//Render the camera cam.Render();
//Clear the RenderTexture again tex.DiscardContents();
In this example, we create a RenderTexture and clear its contents using the DiscardContents method. We then set the RenderTexture as the target for a camera and render the camera. Finally, we clear the RenderTexture again to prepare it for another use.
Package/Library: UnityEngine.CoreModule.
C# (CSharp) UnityEngine RenderTexture.DiscardContents - 28 examples found. These are the top rated real world C# (CSharp) examples of UnityEngine.RenderTexture.DiscardContents extracted from open source projects. You can rate examples to help us improve the quality of examples.