Texture is not assigned to the material in a 2d object that contains a sprite renderer.

I am making a mirror in my 2D game, it is simply a camera to which in its output I assign a texture, that texture is assigned to a material and that material is assigned to a 2d object that contains a sprite renderer.

Everything goes correctly by clicking on the material, dragging the respective texture, and assigning this material to the object’s sprite renderer. The problem is in the final part of the inspector where the information of the material is seen, the base map is automatically changed by the image.png of the sprite renderer, I don’t want that, I want to assign the texture that has as output the camera, I try to drag it again and nothing happens, it continues with the image of the sprite renderer.

I don’t know if this is a bug in the editor, I have reviewed everything I do and as far as I can see it is correct. Unity version: 2022.3.15f1

My project contains URP for lighting issues.

I appreciate any help, I’ve been trying to fix this for several days.

sprite renderer only displays sprites not textures

if you want to display texture use a quad instead of a sprite renderer

Thanks for your response.

It’s strange in version 2019.4.40f1 I was able to make this effect with a sprite renderer with the shape of my mirror, I placed the material with the texture showing a camera.

I had to change version for various reasons, I am now on the aforementioned 2022.3.15f1 and in this newer version it doesn’t work.

Please see attached image:

are you sure you did it with a sprite renderer?

but like i told you, a sprite renderer cannot display a texture, only a sprite, you need to use sprite.create from a texture to use a sprite renderer for that

I assume that you are using a camera and feeding it into a render texture

to display a render texture you should create a quad and put the material on that

Yes, I did it with a sprite renderer, I did it as it is in this video:

Anyway I could get to the cause of the problem, it is in the property “_MainTex” of the material shader, so I created a new shader without this property, since “_MainTex” what it does is to assign the sprite from the sprite renderer as texture automatically, already the mirror works as I want.

It is worth mentioning that the property “_MainTex” is required by the sprite renderer, but it works anyway. I don’t really know if this will hurt me but I’ll leave it like this for the moment, since the mirror works correctly.

1 Like

Thanks for the info. I wonder why it is like this.