Open stelcheck opened 7 years ago
We might not even need the namespace after all:
var mageType = typeof(Wizcorp.MageSDK.MageClient.Module<>);
var modulesList = new List<string> ();
var types = Assembly
.GetExecutingAssembly()
.GetTypes();
foreach(Type type in types) {
var baseType = type.BaseType;
if (baseType == null) {
continue;
}
if (baseType.IsGenericType == false) {
continue;
}
if (baseType.GetGenericTypeDefinition().Equals(mageType) == false) {
continue;
}
Debug.Log("MAGE: found module " + type.FullName);
modulesList.Add(type.Name);
}
return modulesList;
Description
Find a way to dynamically find all MAGE modules in need of setup at runtime, and set them up.
Purpose
I believe this would help with:
Notes
Since this would depend on reflection, I am not sure if this would play well when pushing on a device; I only tested this quickly on a local project running in the editor, and it seemed to work fine. It would be even better if we could feed in the actual namespace instead of a string representation (to avoid typo there by triggering compile-time errors), but would be happy to research that.
cc @AlmirKadric @nullorvoid @kefniark