i need to change the texture of multiple surfaces that have the same material.
so i thought the best way could be to get the name of the material and use it to change the texture of the surfaces having that material.
but its not working
using UnityEngine;
using System.Collections;
public class findmaterialname : MonoBehaviour {
public GameObject g;
public Texture[] myTextures = new Texture[5];
int maxTextures;
int arrayPos = 0;
// Use this for initialization
void Start () {
string s=g.renderer.material.name;
}
// Update is called once per frame
void Update () {
if(g.renderer.material.name=="car")
{
if (Input.GetKeyDown(KeyCode.T))
{
renderer.material.mainTexture = myTextures[arrayPos];
if(arrayPos == maxTextures)
{
arrayPos = 0;
}
else
{
arrayPos++;
}
}
}
}
}