I have 2 scripts. One with this function:
public void UpdateTexture (int texture)
{
foreach (Transform side in transform)
{
side.renderer.material.SetTextureScale("_MainTex", size);
side.renderer.material.SetTextureOffset("_MainTex", new Vector2(textures[texture].x*size.x, textures[texture].y*size.y));
}
}
and another script that is trying to call on that function:
currentSide.GetComponent<BlockScript>().UpdateTexture(0);
When the first script calls on the function it is correct. But when i call on that function from a different script, the texture is different and wrong. What is going on and how could i fix it? thanks