You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Not forgetting to add a module to the setup list; this is easy to forget and causes minor time wastes.
Avoiding issues with typos in the list; you cannot make typos in code you do not have to write
Notes
varmodulesNamespace="MyGame.Mage.Modules";varmodulesList=newList<string>();vartypes=Assembly.GetExecutingAssembly().GetTypes();foreach(Typetypeintypes){if(type.IsVisible&&String.Equals(type.Namespace,modulesNamespace)){Debug.Log("MAGE: found module "+type.Name);modulesList.Add(type.Name);}}
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.
varmageType=typeof(Wizcorp.MageSDK.MageClient.Module<>);varmodulesList=newList<string>();vartypes=Assembly.GetExecutingAssembly().GetTypes();foreach(Typetypeintypes){varbaseType=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);}returnmodulesList;
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
The text was updated successfully, but these errors were encountered: