Description
Are there any plans to allow LuaObjectAttribute to just support C# constructors?
For example, instead of having to specify
[LuaMember("create")]
public static MyCustomClass Create()
{
return new MyCustomClass();
}
Can we just have public constructors to do this? And we just register the Type in the environment like so:
LuaState.Environment["MyCustomType"] = typeof(MyCustomType);
OR
LuaState.Environment.RegisterType<MyCustomType>();
Then on the lua side it would look something like this:
local myType = MyCustomType(1, 2, 3)
OR
local myType = MyCustomType.create(1, 2, 3)
OR
local myType = MyCustomType.new(1, 2, 3)
I know the last two options are personal preference whether to use new/create, so maybe add an argument to LuaObjectAttribute to custom define the function name for new/create or something? I hope I explained my thought process well enough for you to get the idea. I'm curious your thoughts on this?
Edit:
Maybe even just add another attribute that can be applied to constructors that basically generates the same code as my example Create method? Ideally I think it would be nice to just use constructors instead of having to create static methods to construct the custom types