So I’m aware that you shouldn’t use constructors for gameOjects… how do you then assure that a object has all the parameters it needs?
For example, I have a Person object with a name, abilities, location, biography, etc.
Normally I’d have a Person constructor that takes in these things as parameters, since there shouldn’t be a Person without them.
Since Constructors are “bad”, when I use Instantiate, I can create a Person who doesn’t have any name/location/etc. Then in whatever I use to instantiate, I have to make sure I assign to every variable required without missing one, and also make sure that the object isn’t interacted with in some form before it completes.
Say, if I’m drawing people on the screen with their names above their head. What if the GUI update runs and tried to draw this person before their various generators finish populating the Person variables? I’ve considered making a list of “finished people” that they’re added to when the generator is done, but this all seems very backwards as opposed to just using a Constructor.
If I was to basically put all this logic in Awake(), and have the Person class look at a reference to the “Factory” (with all the bulky variable generators) and use its methods to generate its data, will that fire before other updates run? Is that what I’m actually supposed to do in this case or is it as messy as it looks?
There’s no reason for a Person to know the Factory, but in this case every Person has to have that reference.