I have this class:
public abstract class MyClass
{
public abstract string abstract id { get; protected set; }
public abstract Dictionary<string, int> values { get; protected set; }
public MyClass() { this.Initialize(); }
void Initialize() { /*...*/ }
}
I made multiple override scripts of this class and I want to initialize them at Start.
When the constructor is called and initialize method is invoked, the script initialize with some data and then it adds itself to the manager script.
The problem is that I don't want to do this:
public class Manager : MonoBehaviour
{
public void Start()
{
new OverrideOfMyClass_1();
new OverrideOfMyClass_2();
new OverrideOfMyClass_3();
new OverrideOfMyClass_4();
//..
}
}
I store all these override scripts inside certain folder.
So Instead I fetched all .cs type files from the Directory using DirectoryInfo and.. I got stuck after this point as I don't know how to get the class type and instantiate it, so that the constructor would be called and initialize method invoked.
Is there a way to do this?