I have two scripts in my game, a Grid Script and a Properties Script. The Grid creates an X by Y grid of cubes where each individual cube has a “Properties” Script. In properties I have a height variable that I would like the Grid Script to set. Basically I have:
for (int i = 0; i < gridArr.GetLength(0); i++){
for (int k = 0; k < gridArr.GetLength(1); k++){
if (!(GameObject.Find(i+","+k) != null)) {
GameObject obj = Instantiate(fill, new Vector3(i, 0, k),
Quaternion.identity) as GameObject;
obj.name = (i+","+k);
obj.AddComponent("Properties");
gridArr[i,k] = obj;
}
}
}
In the Grid Script and then I have:
public class Properties : MonoBehaviour {
public int height;
}
In the Properties class. How would I go about modifying the height variable in this Class?