Scaling material without saving scale on original material
Hello, I am looking for a way to scale a material on a game object without scaling all the same materials in the scene. By default, my material is 1x1. I scale it to 2x5 on a game object. But i then realize that all of the game objects that have that same materials on will be scaled 2x5 as well, and thats what I am trying to avoid.
Is there someting i can do in the mesh renderer?
(If you dont understand, i mean to make a gameobject unique material scaling without making a whole new material)
Thanks for the help :)
Can you have the texture as a child to your GameObject and scale the child ins$$anonymous$$d?
I am trying to scale the material, not the gameobject
I understand. You would be able to keep the scale of your parent GameObject as whatever you want, while changing the scale of the child texture.
I see what you mean, but the material's scale will still be applied to the material in the assets folder...
What do i have to do if i want a cube with the texture scaled 1x2 and another cube that its texture is scaled 1x1 with the exact same texture? what it does is that both is 1x2 or 1x1, thats my issue because the last scale i put on one will be applied on every gameobject that has that texture...
Thats why im talking about a "gameobject unique texture scale" setting, so that every cube in the scene has its independant texture scale, or else every cube has the same texture scale that is taken from the material in the assets folder
Answer by Umresh · Aug 24, 2015 at 09:06 AM
You can attach the material at run time using script and set the offset. In this wat instance of the material is created and you can have different scale for different cubes
if(this.GetComponent<MeshRenderer>())
{
MeshRenderer _meshRenderer = this.GetComponent<MeshRenderer>();
_meshRenderer.material = _material;
_meshRenderer.material.mainTextureScale = Vector2.one *2;//Your desired scale
}
Thanks, thats perfect!
But is there a meshRenderer.material.mainTextureScale option in the inspector?
In the mesh renderer component? Because if it is in the material itself, it will bring the issue again...