Initialising script component with parameters

I’m new to using Unity, although I am not new to coding. I am writing some code to create game objects in different empty game objects, creating an easily browsable hierarchy. So to do this, I have a ‘root’ empty object which has a script which creates empty game objects in its start function:

        GameObject emptyObj = new GameObject (); = "Sub-Object1";
		emptyObj.transform.parent = this.gameObject.transform;
		SubObject subObj = emptyObj.AddComponent<SubObject> ();
		subObj.Start ();

I want to pass parameters to this new script… However Unity doesn’t like parameters in the start function. I am currently just using a function in the SubObject script which takes the parameters and have moved the code from the start function to that new function, leaving the start function empty. Is this the right way to do this, or is there a better way?

Normally you should not call “Start” or “Awake” functions yourself because they are called automatically if gameobject is active. If you want to set some parameters like you said, you could create your own Init(…) method. Or make necessary parameters public property or field and set them.

Reckless usage of “Awake” and “Start” functions becomes the root of all evil bugs when the project grows.