I'm trying to make decision in my script if I get a value 1 then run specific game object which is (PopulationGenerator
of population engine asset). I have 3 population generator in my scene but I can't assign any of them pragmatically in the code to PopulationGenerator
variable.
The only way is drag and drop gameobject from side menu on the script in the unity GUI.
This is the code:
public PopulationGenerator generate1;
generat1.totalToSpawn = Convert.ToInt32(number) - 5;
Can i set one of Population Generators in scene like for example
if (value == 1)
generate1 = gameobject.name("generator1");
else if (value == 2)
generate1 = gameobject.name("generator2");
...
Is there any method to set a gameobject of any type to a variable in the code ? Thanks.