- Home /
Blitting a Texture once
When working with Graphics.Blit(), I have noticed that the Texture being drawn onto the RenderTexture as multiple times even if Graphics.Blit() is only called once. Here's an example of what I mean.
Below is a the entire script I am using to call Graphics.Blit()
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class SuperBasicBlitTest : MonoBehaviour
{
private RenderTexture renderTexture;
public Texture blitTexture;
void Start()
{
this.renderTexture = (RenderTexture) this.gameObject.GetComponent<RawImage>().texture;
Graphics.Blit(blitTexture, renderTexture, new Vector2(10.0f, 10.0f), new Vector2(-0.5f, -0.5f));
}
void Update()
{
}
}
The only call to Graphics.Blit() is in during Start() which should only be called once, as only one object has this script. Here is the image I was using as the source: But Once I call the Blit, the destination begins to look like this:
The same image appears 10 times because I scaled it to takes up a 10th of the destination RenderTexture. My question is, how can I scale it in this was without causing the same image to appear multiple times?
What I want to know is, how can I make sure that the source image appears only once and without giving up control over the size and position of the source texture.