private void CreateMenu() { Type[] types = AssemblyUtility.GetDerivedTypes(typeof(AssetPostRuler)); genericMenu = new GenericMenu(); foreach (var type in types) { AssetPostRulerMenuAttribute attr = type.GetCustomAttribute <AssetPostRulerMenuAttribute>(); if (attr != null) { genericMenu.AddItem(new GUIContent(attr.MenuName), false, (t) => { var obj = ScriptableObject.CreateInstance((Type)t); obj.name = attr.FileName; AssetDatabase.AddObjectToAsset(obj, target); rulerProperty.AddElement(obj); EditorUtility.SetDirty(target); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target)); }, type); } } }