Why doesn't my texture show up?


I’m trying to make an image show up when the player clicks on one of the objects in my game. However, the code doesn’t seem to be working. Can someone experienced help me?

Thank you so much!

Here’s the code:

bool showPaw=false;
	public Texture2D catPaw;

	void OnMouseDown () {

		showPaw = true;

	void OnGUI (){
		if (showPaw == true)
			GUI.DrawTexture(new Rect(0,0, 100,100),catPaw,ScaleMode.ScaleToFit); 
			Debug.Log("CAT PAW!!");

Thanks for your answers, but I’ve fixed the problem. I wrote a separate script so that destroying the game object won’t affect my image showing up. I’ve made the image a sprite instead of a texture2D. Here’s the code for those interested:

	private SpriteRenderer spriteRenderer;
	public Sprite[] catPaw; 

	void Start(){
		spriteRenderer = GetComponent<SpriteRenderer> ();
		spriteRenderer.enabled = false; //makes sure that the image won't show up at first

	void FixedUpdate(){
		if (destroyMouse.showPaw == true) { 
			spriteRenderer.enabled = true; //makes the image show up

		else {
			spriteRenderer.enabled = false; //when "showPaw==false", make the image disappear again
		GetComponent<SpriteRenderer>().sprite = catPaw[0];