Hey there folks. I’m pretty new so apologies for a probably silly question. Is it possible to pass an Instance some parameters before its Start() gets executed? Because this is what I’d like to do:
Create an instance of a script
Set some values
Execute its Start()
My current work-around is by adding a new methodPostStart()to the instance and calling it like this:
Well sounds like you are trying to add the script which yes of course you will need the addComponent to add the script. After I don’t understand why you couldn’t do foo = new Foo(params); as this is a constructor and can be done. Just setup a constructor inside your class, and good to go? Best to look up constructors with Unity on how to accomplish this.
Thanks for your suggestions. Alright, I guess it works when I create a sub-class with a proper constructor like I head before. My error was that it was not a sub-class but a wholly separate class and that’s why Unity wasn’t allowing it.
I grasp the basics of OOP and love to compartmentalize my code but I still have a lot to learn about best practices because I am over-complicating things for myself in my little test prototype