Hello there. I have been trying to make an GameObject change it’s texture by clicking it during the game. I made GameObject named “tile” which is located in materials/prefabs and it’s texture already defined. Then I have 2 variables as 2D Textures. My code generates a grid of tiles, I’d like them to change their texture on click.
How I can access the texture in the Tile object? How do I can make it respond when the GameObject tile is being clicked? I’d like the function to access it’s texture and change it on click.
renderer.material.mainTexture = texture;
OR
renderer.material.SetTexture(“_MainTex”, texture);
Read Input to learn about how to handle click events.