Unity-CSharp-Mod
Unity-CSharp-Mod copied to clipboard
Non Monobehaviour scripts
I seem to have hit a wall, if we only use MonoBehaviour scripts (Moddable) then how would we go about creating classes and we want to create multiple instances of?
For example,
public class Block{
string name;
public Block(string name)
{
this.name = name;
}
}
And then in another script:
Block block = new Block();
This would fail if Block inherited MonoBehaviour as monobehaviour scripts cannot be "instantiated". I think the limitation for this lies within System.Activator.CreateInstance, but haven't figured out a work around yet.
This seems to be a common issue and I have also created a similar issue
System.Activator.CreateInstance(type, param1, param2, param3 ...)
Seems to be work, now just need to find a nice way to integrate this solution in an intuitive way!
This is just a thought but it might work by simply removing the MonoBehaviour on Moddable
Hmm actually nevermind, I think it should work if we just ignore the non mono scripts...