Instantiate a Prefab *and* initialise some of its properties in c#?

Hi all,

I have a main game script in c# that is successfully instantiating prefabs. On my prefab I have just attached a script exposing three public properties. I can see these properties in the property inspector.

Is it possible to set those properties through c# code at the same time as I instantiate the prefab?

Yes, you should be able to call it like this:

GameObject go = (GameObject)Instantiate(prefab, Vector3.zero, Quaternion.identity);
SomeComponent comp = go.GetComponent<SomeComponent>();
comp.property1 = "blah";
comp.property2 = 2;
ect...