private void BuildMenu(GenericMenu menu, Type type, string itemVisiblePath, string itemInternalPath, bool addSelf, int depth, GenericMenu.MenuFunction2 function) { if (addSelf) { menu.AddItem(new GUIContent(itemVisiblePath + "/" + type.Name), false, function, itemInternalPath); } var members = UTComponentScanner.FindPublicWritableMembersOf(type); foreach (var memberInfo in members.MemberInfos) { var newInternalPath = string.IsNullOrEmpty(itemInternalPath) ? memberInfo.Name : itemInternalPath + "." + memberInfo.Name; var newVisiblePath = string.IsNullOrEmpty(itemVisiblePath) ? memberInfo.Name : itemVisiblePath + "/" + memberInfo.Name; if (memberInfo.DeclaringType != typeof(Component)) { var memberInfoType = UTInternalCall.GetMemberType(memberInfo); if (UTInternalCall.HasMembers(memberInfoType) && depth < 2) { BuildMenu(menu, memberInfoType, newVisiblePath, newInternalPath, UTInternalCall.IsWritable(memberInfo), depth + 1, function); } else { menu.AddItem(new GUIContent(newVisiblePath), false, function, newInternalPath); } } } }
public static UTMemberListResult FindPublicWritableMembersOf(Type type) { if (memberListCache.ContainsKey(type)) { return(memberListCache [type]); } var allMembers = UTInternalCall.PublicMembersOf(type); UTMemberListResult result = new UTMemberListResult(Array.FindAll(allMembers, item => UTInternalCall.IsWritable(item))); memberListCache.Add(type, result); return(result); }