I’m attempting to generate a list of corporations, each one with randomized values. So far, this is working, but I can’t help but think something in here could be done a lot better. Specifically, the code to fetch the Corporation prefab takes three lines, and requires the corporation to be in a “resources” folder instead of just in the asset folder.
Is there a simpler way to fetch an object? Is this janky fix how it actually works?
void generate()
{
int corpsToMake = 10;//# of corps to make
corpSet = new Corporation[corpsToMake];
shares = new int[corpsToMake];
for(int i = 0; i < corpsToMake; i++)
{
GameObject tempCorp = (GameObject) Instantiate(Resources.Load("Corporation"));
corpListSize++;
Corporation corp = (Corporation) tempCorp.GetComponent("Corporation");
corpSet *= corp;*
_ Corporation cs = (Corporation) corpSet*.GetComponent();_
_ cs.setName(nameGen());_
_ //cs.setName(Random.Range(1,100).ToString());_
_ cs.setShares(Random.Range(50,100));_
_ cs.setID(i+1);_
_ }_
_// GameObject player = (GameObject) Instantiate(Resources.Load(“Corporation”));_
_// playerCorp = (Corporation) player.GetComponent(“Corporation”);_
_// playerCorp.setID(100);_
_// playerCorp.setName(“LevelZero”);_
_// playerCorp.setShares(10000);_
_// playerCorp.player = true;_
_ afterGen(); _
_ }*_