I'm new to unity and am having a bit of trouble getting my head around the architecture.
Lets say I have a C# script component called 'component A'. I'd like component A to have an array of 100 other components of type 'component B'. How do I construct the 'component B's programmatically with certain values?
Note that 'component B' is derived from 'MonoBehaviour' as it needs to be able to call 'StartCoroutine'
I'm aware that in unity you do not use constructors as you normally would in OO.
That's true. A possibility is to istantiate components at runtime and provide a method to initialize them ( if initialization requires arguments, otherwise all initialization can be done inside
Start
orAwake
methods ).Here's a possible way:
Note that in the example above all components will be attached to the same GameObject, this might be not what you want. Eventually try to give more details.