Skip to main content

RenderTextureGetter

A class in Root.Township, the global namespace.

Client: borrows a temporary render texture on request and hands it to a material and/or camera; releases it on clear or destroy.

Constructors​

MemberWhat it is
RenderTextureGetter()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

5 private and internal fields
MemberWhat it is
private Camera cameraToRenderOptional camera whose target texture is set.
private SerializedRenderTextureDescriptor descriptorSettings for the texture to create.
private int materialIndexShader property ID for materialKeyword.
private string materialKeywordMaterial texture property to set, _MainTex by default.
private Material materialToSetTextureOptional material that gets the texture.

Properties​

MemberWhat it is
RenderTexture RenderTexture { get; private set; }The texture currently held, or null.

Events​

MemberWhat it is
event Action<RenderTexture> onRenderTextureUpdatedFired with the new texture (or null) when it changes.

Methods​

MemberWhat it is
void Clear()Releases the texture and tells listeners it's gone. Skipped when headless.
void GetTexture()Gets a temporary texture from the descriptor if there isn't one. Skipped when headless.
3 private and internal methods
MemberWhat it is
private void Awake()Wires the material texture and camera target to update when the texture changes.
private void OnDestroy()Releases the texture.
private void SetTexture(RenderTexture renderTexture)Stores the texture and fires onRenderTextureUpdated.