void AddEmitterTypeMenu()
{
List<GUIContent> Menu = new List<GUIContent>();
Dictionary<string, System.Type> EMTypes = new Dictionary<string, System.Type>();
// Get a list of classes that derive from MBEmitterType
Assembly asm = Assembly.GetAssembly(typeof(MBEmitterType));
System.Type[] types = asm.GetTypes();
foreach (System.Type T in types) {
// Get MBEmitterTypeInfo-Attribute
System.Attribute info = System.Attribute.GetCustomAttribute(T, typeof(MBEmitterTypeInfo));
if (info != null) {
// Add menu entry
Menu.Add(new GUIContent(((MBEmitterTypeInfo)info).Menu));
// Link menu entry to class
EMTypes.Add(((MBEmitterTypeInfo)info).Menu, T);
}
}
EditorUtility.DisplayCustomMenu(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 100, 100),
Menu.ToArray(), -1, OnAddEmitterTypeMenu, EMTypes);
}