***public class maze : MonoBehaviour {
public GameObject wall;
public GameObject floor1;
public float xsize = 5.0f;
public float ysize = 5.0f;
public float wallLength = 1.0f;
public Vector3 intposition;
private GameObject wallfolder;
public Material floormat;
public GameVar data;
public void CreateWalls()
{
intposition = new Vector3(-xsize / 2, 0.0f, (-ysize / 2) + (wallLength/2));
Debug.Log(intposition);
Vector3 myposition = intposition;
GameObject tempWall;
wallfolder = new GameObject();
wallfolder.name = ("wall folder");
//for bottom plane
//for x axis
for (int i = 0; i < ysize; i++)
{
for (int j = 0; j <= xsize; j ++)
{
myposition = new Vector3 (intposition.x + (j * wallLength) - wallLength / 2, 0.0f, intposition.z + (i * wallLength) - wallLength / 2);
tempWall = Instantiate(wall, myposition, Quaternion.identity) as GameObject;
tempWall.transform.parent = wallfolder.transform;
}
}
//for y axis
for (int i = 0; i <= ysize; i++)
{
for (int j = 0; j < xsize; j++)
{
myposition = new Vector3(intposition.x + (j * wallLength) , 0.0f, intposition.z + (i * wallLength) - wallLength );
tempWall = Instantiate(wall, myposition, Quaternion.Euler(0f, 90f, 0f)) as GameObject;
tempWall.transform.parent = wallfolder.transform;
}
}
}***
I made a script that creates a basic room shape through well cell prefabs, however, the prefabs always have no material in the mesh renderer, regardless of whether the prefab has a material. I am quite lost =/ How would I change the material of an object if I don’t have the reference??