Not sure I’ve worded that correctly…
But let’s say I have a Cube prefab. I instantiated 5X5 Cube prefabs so that they form a 5X5 grid.
Now, I want a Cube to have a property, something like “isSet”. If isSet is true, then the Cube is yellow. Otherwise, the Cube is red (just the default color).
So, in some main script, I have a loop that creates the grid of Cubes:
public class MainScript: MonoBehavior {
public Transform cube;
public start() {
SomeScript script;
GameObject obj;
for (int i=0... {
for (int j=0... {
obj = (GameObject)Instantiate(cube....
script = obj.GetComponent<ZoneTypeScript>();
script.isSet = true;
}
}
}
}
Now, a prefab is a prefab, so it’s not like I can just add a property to it. But I could add a MonoBehaviour script that perhaps has the property I want to set, no? But how would I change the property in the loop above?
Thanks.